diff options
author | Denis Vlasenko | 2006-12-23 01:06:21 +0000 |
---|---|---|
committer | Denis Vlasenko | 2006-12-23 01:06:21 +0000 |
commit | 2a813e20e2a8720160a059a036cb6c066044f709 (patch) | |
tree | 607468384b6707c7b60505da37d2aefc49d355cf /libbb/u_signal_names.c | |
parent | 8f6c79240dc7c1e0b819a1a1309240477d8e0d84 (diff) | |
download | busybox-2a813e20e2a8720160a059a036cb6c066044f709.zip busybox-2a813e20e2a8720160a059a036cb6c066044f709.tar.gz |
fix recognitions of -SIGname signals
(fix by Jacques LUDER <jacques.luder@thalesgroup.com>)
Diffstat (limited to 'libbb/u_signal_names.c')
-rw-r--r-- | libbb/u_signal_names.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/libbb/u_signal_names.c b/libbb/u_signal_names.c index 88311dd..eb835e9 100644 --- a/libbb/u_signal_names.c +++ b/libbb/u_signal_names.c @@ -15,7 +15,8 @@ static const struct signal_name { } signals[] = { // SUSv3 says kill must support these, and specifies the numerical values, // http://www.opengroup.org/onlinepubs/009695399/utilities/kill.html - {0, "0"}, {1, "HUP"}, {2, "INT"}, {3, "QUIT"}, {6, "ABRT"}, {9, "KILL"}, + // TODO: "[SIG]EXIT" shouldn't work for kill, right? + {0, "EXIT"}, {1, "HUP"}, {2, "INT"}, {3, "QUIT"}, {6, "ABRT"}, {9, "KILL"}, {14, "ALRM"}, {15, "TERM"}, // And Posix adds the following: {SIGILL, "ILL"}, {SIGTRAP, "TRAP"}, {SIGFPE, "FPE"}, {SIGUSR1, "USR1"}, @@ -30,13 +31,13 @@ int get_signum(const char *name) { int i; - i = atoi(name); - if (i) return i; + i = bb_strtou(name, NULL, 10); + if (!errno) return i; for (i = 0; i < sizeof(signals) / sizeof(struct signal_name); i++) - if (!strcasecmp(signals[i].name, name) || - (!strncasecmp(signals[i].name, "SIG", 3) - && !strcasecmp(signals[i].name+3, signals[i].name))) - return signals[i].number; + if (strcasecmp(name, signals[i].name) == 0 + || (strncasecmp(name, "SIG", 3) == 0 + && strcasecmp(&name[3], signals[i].name) == 0)) + return signals[i].number; return -1; } |