diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-12-04 21:44:52 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-12-04 21:44:52 +0000 |
commit | b851c42a1445c67159279d8af59965e092268ce6 (patch) | |
tree | 3e3baa1b57158b0cead699f45ad3a73ee5e395d9 /libbb/u_signal_names.c | |
parent | f3fca91e9f427f2b026df07607c8b903aed93395 (diff) | |
download | busybox-w32-b851c42a1445c67159279d8af59965e092268ce6.tar.gz busybox-w32-b851c42a1445c67159279d8af59965e092268ce6.tar.bz2 busybox-w32-b851c42a1445c67159279d8af59965e092268ce6.zip |
signal names hack was wrong, it broke "get signal name" function.
Reverting :(
Diffstat (limited to 'libbb/u_signal_names.c')
-rw-r--r-- | libbb/u_signal_names.c | 83 |
1 files changed, 40 insertions, 43 deletions
diff --git a/libbb/u_signal_names.c b/libbb/u_signal_names.c index c741f81d7..97e9949e9 100644 --- a/libbb/u_signal_names.c +++ b/libbb/u_signal_names.c | |||
@@ -9,9 +9,10 @@ | |||
9 | 9 | ||
10 | #include "libbb.h" | 10 | #include "libbb.h" |
11 | 11 | ||
12 | #define KILL_MAX_SIG 32 | 12 | /* Believe it or not, but some arches have more than 32 SIGs! |
13 | * HPPA: SIGSTKFLT == 36. */ | ||
13 | 14 | ||
14 | static const char signals[KILL_MAX_SIG][6] = { | 15 | static const char signals[][7] = { |
15 | // SUSv3 says kill must support these, and specifies the numerical values, | 16 | // SUSv3 says kill must support these, and specifies the numerical values, |
16 | // http://www.opengroup.org/onlinepubs/009695399/utilities/kill.html | 17 | // http://www.opengroup.org/onlinepubs/009695399/utilities/kill.html |
17 | // {0, "EXIT"}, {1, "HUP"}, {2, "INT"}, {3, "QUIT"}, | 18 | // {0, "EXIT"}, {1, "HUP"}, {2, "INT"}, {3, "QUIT"}, |
@@ -22,102 +23,98 @@ static const char signals[KILL_MAX_SIG][6] = { | |||
22 | // {SIGCONT, "CONT"}, {SIGSTOP, "STOP"}, {SIGTSTP, "TSTP"}, {SIGTTIN, "TTIN"}, | 23 | // {SIGCONT, "CONT"}, {SIGSTOP, "STOP"}, {SIGTSTP, "TSTP"}, {SIGTTIN, "TTIN"}, |
23 | // {SIGTTOU, "TTOU"} | 24 | // {SIGTTOU, "TTOU"} |
24 | 25 | ||
25 | /* Believe it or not, but some arches have more than 32 SIGs! | ||
26 | * HPPA: SIGSTKFLT == 36. We don't include those. */ | ||
27 | |||
28 | /* NB: longest (6-char) names are NOT nul-terminated */ | ||
29 | [0] = "EXIT", | 26 | [0] = "EXIT", |
30 | #if defined SIGHUP && SIGHUP < KILL_MAX_SIG | 27 | #ifdef SIGHUP |
31 | [SIGHUP ] = "HUP", | 28 | [SIGHUP ] = "HUP", |
32 | #endif | 29 | #endif |
33 | #if defined SIGINT && SIGINT < KILL_MAX_SIG | 30 | #ifdef SIGINT |
34 | [SIGINT ] = "INT", | 31 | [SIGINT ] = "INT", |
35 | #endif | 32 | #endif |
36 | #if defined SIGQUIT && SIGQUIT < KILL_MAX_SIG | 33 | #ifdef SIGQUIT |
37 | [SIGQUIT ] = "QUIT", | 34 | [SIGQUIT ] = "QUIT", |
38 | #endif | 35 | #endif |
39 | #if defined SIGILL && SIGILL < KILL_MAX_SIG | 36 | #ifdef SIGILL |
40 | [SIGILL ] = "ILL", | 37 | [SIGILL ] = "ILL", |
41 | #endif | 38 | #endif |
42 | #if defined SIGTRAP && SIGTRAP < KILL_MAX_SIG | 39 | #ifdef SIGTRAP |
43 | [SIGTRAP ] = "TRAP", | 40 | [SIGTRAP ] = "TRAP", |
44 | #endif | 41 | #endif |
45 | #if defined SIGABRT && SIGABRT < KILL_MAX_SIG | 42 | #ifdef SIGABRT |
46 | [SIGABRT ] = "ABRT", | 43 | [SIGABRT ] = "ABRT", |
47 | #endif | 44 | #endif |
48 | #if defined SIGBUS && SIGBUS < KILL_MAX_SIG | 45 | #ifdef SIGBUS |
49 | [SIGBUS ] = "BUS", | 46 | [SIGBUS ] = "BUS", |
50 | #endif | 47 | #endif |
51 | #if defined SIGFPE && SIGFPE < KILL_MAX_SIG | 48 | #ifdef SIGFPE |
52 | [SIGFPE ] = "FPE", | 49 | [SIGFPE ] = "FPE", |
53 | #endif | 50 | #endif |
54 | #if defined SIGKILL && SIGKILL < KILL_MAX_SIG | 51 | #ifdef SIGKILL |
55 | [SIGKILL ] = "KILL", | 52 | [SIGKILL ] = "KILL", |
56 | #endif | 53 | #endif |
57 | #if defined SIGUSR1 && SIGUSR1 < KILL_MAX_SIG | 54 | #ifdef SIGUSR1 |
58 | [SIGUSR1 ] = "USR1", | 55 | [SIGUSR1 ] = "USR1", |
59 | #endif | 56 | #endif |
60 | #if defined SIGSEGV && SIGSEGV < KILL_MAX_SIG | 57 | #ifdef SIGSEGV |
61 | [SIGSEGV ] = "SEGV", | 58 | [SIGSEGV ] = "SEGV", |
62 | #endif | 59 | #endif |
63 | #if defined SIGUSR2 && SIGUSR2 < KILL_MAX_SIG | 60 | #ifdef SIGUSR2 |
64 | [SIGUSR2 ] = "USR2", | 61 | [SIGUSR2 ] = "USR2", |
65 | #endif | 62 | #endif |
66 | #if defined SIGPIPE && SIGPIPE < KILL_MAX_SIG | 63 | #ifdef SIGPIPE |
67 | [SIGPIPE ] = "PIPE", | 64 | [SIGPIPE ] = "PIPE", |
68 | #endif | 65 | #endif |
69 | #if defined SIGALRM && SIGALRM < KILL_MAX_SIG | 66 | #ifdef SIGALRM |
70 | [SIGALRM ] = "ALRM", | 67 | [SIGALRM ] = "ALRM", |
71 | #endif | 68 | #endif |
72 | #if defined SIGTERM && SIGTERM < KILL_MAX_SIG | 69 | #ifdef SIGTERM |
73 | [SIGTERM ] = "TERM", | 70 | [SIGTERM ] = "TERM", |
74 | #endif | 71 | #endif |
75 | #if defined SIGSTKFLT && SIGSTKFLT < KILL_MAX_SIG | 72 | #ifdef SIGSTKFLT |
76 | [SIGSTKFLT] = "STKFLT", | 73 | [SIGSTKFLT] = "STKFLT", |
77 | #endif | 74 | #endif |
78 | #if defined SIGCHLD && SIGCHLD < KILL_MAX_SIG | 75 | #ifdef SIGCHLD |
79 | [SIGCHLD ] = "CHLD", | 76 | [SIGCHLD ] = "CHLD", |
80 | #endif | 77 | #endif |
81 | #if defined SIGCONT && SIGCONT < KILL_MAX_SIG | 78 | #ifdef SIGCONT |
82 | [SIGCONT ] = "CONT", | 79 | [SIGCONT ] = "CONT", |
83 | #endif | 80 | #endif |
84 | #if defined SIGSTOP && SIGSTOP < KILL_MAX_SIG | 81 | #ifdef SIGSTOP |
85 | [SIGSTOP ] = "STOP", | 82 | [SIGSTOP ] = "STOP", |
86 | #endif | 83 | #endif |
87 | #if defined SIGTSTP && SIGTSTP < KILL_MAX_SIG | 84 | #ifdef SIGTSTP |
88 | [SIGTSTP ] = "TSTP", | 85 | [SIGTSTP ] = "TSTP", |
89 | #endif | 86 | #endif |
90 | #if defined SIGTTIN && SIGTTIN < KILL_MAX_SIG | 87 | #ifdef SIGTTIN |
91 | [SIGTTIN ] = "TTIN", | 88 | [SIGTTIN ] = "TTIN", |
92 | #endif | 89 | #endif |
93 | #if defined SIGTTOU && SIGTTOU < KILL_MAX_SIG | 90 | #ifdef SIGTTOU |
94 | [SIGTTOU ] = "TTOU", | 91 | [SIGTTOU ] = "TTOU", |
95 | #endif | 92 | #endif |
96 | #if defined SIGURG && SIGURG < KILL_MAX_SIG | 93 | #ifdef SIGURG |
97 | [SIGURG ] = "URG", | 94 | [SIGURG ] = "URG", |
98 | #endif | 95 | #endif |
99 | #if defined SIGXCPU && SIGXCPU < KILL_MAX_SIG | 96 | #ifdef SIGXCPU |
100 | [SIGXCPU ] = "XCPU", | 97 | [SIGXCPU ] = "XCPU", |
101 | #endif | 98 | #endif |
102 | #if defined SIGXFSZ && SIGXFSZ < KILL_MAX_SIG | 99 | #ifdef SIGXFSZ |
103 | [SIGXFSZ ] = "XFSZ", | 100 | [SIGXFSZ ] = "XFSZ", |
104 | #endif | 101 | #endif |
105 | #if defined SIGVTALRM && SIGVTALRM < KILL_MAX_SIG | 102 | #ifdef SIGVTALRM |
106 | [SIGVTALRM] = "VTALRM", | 103 | [SIGVTALRM] = "VTALRM", |
107 | #endif | 104 | #endif |
108 | #if defined SIGPROF && SIGPROF < KILL_MAX_SIG | 105 | #ifdef SIGPROF |
109 | [SIGPROF ] = "PROF", | 106 | [SIGPROF ] = "PROF", |
110 | #endif | 107 | #endif |
111 | #if defined SIGWINCH && SIGWINCH < KILL_MAX_SIG | 108 | #ifdef SIGWINCH |
112 | [SIGWINCH ] = "WINCH", | 109 | [SIGWINCH ] = "WINCH", |
113 | #endif | 110 | #endif |
114 | #if defined SIGPOLL && SIGPOLL < KILL_MAX_SIG | 111 | #ifdef SIGPOLL |
115 | [SIGPOLL ] = "POLL", | 112 | [SIGPOLL ] = "POLL", |
116 | #endif | 113 | #endif |
117 | #if defined SIGPWR && SIGPWR < KILL_MAX_SIG | 114 | #ifdef SIGPWR |
118 | [SIGPWR ] = "PWR", | 115 | [SIGPWR ] = "PWR", |
119 | #endif | 116 | #endif |
120 | #if defined SIGSYS && SIGSYS < KILL_MAX_SIG | 117 | #ifdef SIGSYS |
121 | [SIGSYS ] = "SYS", | 118 | [SIGSYS ] = "SYS", |
122 | #endif | 119 | #endif |
123 | }; | 120 | }; |
@@ -133,20 +130,20 @@ int get_signum(const char *name) | |||
133 | return i; | 130 | return i; |
134 | if (strncasecmp(name, "SIG", 3) == 0) | 131 | if (strncasecmp(name, "SIG", 3) == 0) |
135 | name += 3; | 132 | name += 3; |
136 | if (strlen(name) > 6) | ||
137 | return -1; | ||
138 | for (i = 0; i < ARRAY_SIZE(signals); i++) | 133 | for (i = 0; i < ARRAY_SIZE(signals); i++) |
139 | if (strncasecmp(name, signals[i], 6) == 0) | 134 | if (strcasecmp(name, signals[i]) == 0) |
140 | return i; | 135 | return i; |
141 | 136 | ||
142 | #if ENABLE_DESKTOP && (defined(SIGIOT) || defined(SIGIO)) | 137 | #if ENABLE_DESKTOP && (defined(SIGIOT) || defined(SIGIO)) |
143 | /* These are aliased to other names */ | 138 | /* SIGIO[T] are aliased to other names, |
139 | * thus cannot be stored in the signals[] array. | ||
140 | * Need special code to recognize them */ | ||
144 | if ((name[0] | 0x20) == 'i' && (name[1] | 0x20) == 'o') { | 141 | if ((name[0] | 0x20) == 'i' && (name[1] | 0x20) == 'o') { |
145 | #if defined SIGIO | 142 | #ifdef SIGIO |
146 | if (!name[2]) | 143 | if (!name[2]) |
147 | return SIGIO; | 144 | return SIGIO; |
148 | #endif | 145 | #endif |
149 | #if defined SIGIOT | 146 | #ifdef SIGIOT |
150 | if ((name[2] | 0x20) == 't' && !name[3]) | 147 | if ((name[2] | 0x20) == 't' && !name[3]) |
151 | return SIGIOT; | 148 | return SIGIOT; |
152 | #endif | 149 | #endif |