signal names hack was wrong, it broke "get signal name" function.

Reverting :(
This commit is contained in:
Denis Vlasenko 2007-12-04 21:44:52 +00:00
parent f3fca91e9f
commit b851c42a14

View File

@ -9,9 +9,10 @@
#include "libbb.h" #include "libbb.h"
#define KILL_MAX_SIG 32 /* Believe it or not, but some arches have more than 32 SIGs!
* HPPA: SIGSTKFLT == 36. */
static const char signals[KILL_MAX_SIG][6] = { static const char signals[][7] = {
// SUSv3 says kill must support these, and specifies the numerical values, // SUSv3 says kill must support these, and specifies the numerical values,
// http://www.opengroup.org/onlinepubs/009695399/utilities/kill.html // http://www.opengroup.org/onlinepubs/009695399/utilities/kill.html
// {0, "EXIT"}, {1, "HUP"}, {2, "INT"}, {3, "QUIT"}, // {0, "EXIT"}, {1, "HUP"}, {2, "INT"}, {3, "QUIT"},
@ -22,102 +23,98 @@ static const char signals[KILL_MAX_SIG][6] = {
// {SIGCONT, "CONT"}, {SIGSTOP, "STOP"}, {SIGTSTP, "TSTP"}, {SIGTTIN, "TTIN"}, // {SIGCONT, "CONT"}, {SIGSTOP, "STOP"}, {SIGTSTP, "TSTP"}, {SIGTTIN, "TTIN"},
// {SIGTTOU, "TTOU"} // {SIGTTOU, "TTOU"}
/* Believe it or not, but some arches have more than 32 SIGs!
* HPPA: SIGSTKFLT == 36. We don't include those. */
/* NB: longest (6-char) names are NOT nul-terminated */
[0] = "EXIT", [0] = "EXIT",
#if defined SIGHUP && SIGHUP < KILL_MAX_SIG #ifdef SIGHUP
[SIGHUP ] = "HUP", [SIGHUP ] = "HUP",
#endif #endif
#if defined SIGINT && SIGINT < KILL_MAX_SIG #ifdef SIGINT
[SIGINT ] = "INT", [SIGINT ] = "INT",
#endif #endif
#if defined SIGQUIT && SIGQUIT < KILL_MAX_SIG #ifdef SIGQUIT
[SIGQUIT ] = "QUIT", [SIGQUIT ] = "QUIT",
#endif #endif
#if defined SIGILL && SIGILL < KILL_MAX_SIG #ifdef SIGILL
[SIGILL ] = "ILL", [SIGILL ] = "ILL",
#endif #endif
#if defined SIGTRAP && SIGTRAP < KILL_MAX_SIG #ifdef SIGTRAP
[SIGTRAP ] = "TRAP", [SIGTRAP ] = "TRAP",
#endif #endif
#if defined SIGABRT && SIGABRT < KILL_MAX_SIG #ifdef SIGABRT
[SIGABRT ] = "ABRT", [SIGABRT ] = "ABRT",
#endif #endif
#if defined SIGBUS && SIGBUS < KILL_MAX_SIG #ifdef SIGBUS
[SIGBUS ] = "BUS", [SIGBUS ] = "BUS",
#endif #endif
#if defined SIGFPE && SIGFPE < KILL_MAX_SIG #ifdef SIGFPE
[SIGFPE ] = "FPE", [SIGFPE ] = "FPE",
#endif #endif
#if defined SIGKILL && SIGKILL < KILL_MAX_SIG #ifdef SIGKILL
[SIGKILL ] = "KILL", [SIGKILL ] = "KILL",
#endif #endif
#if defined SIGUSR1 && SIGUSR1 < KILL_MAX_SIG #ifdef SIGUSR1
[SIGUSR1 ] = "USR1", [SIGUSR1 ] = "USR1",
#endif #endif
#if defined SIGSEGV && SIGSEGV < KILL_MAX_SIG #ifdef SIGSEGV
[SIGSEGV ] = "SEGV", [SIGSEGV ] = "SEGV",
#endif #endif
#if defined SIGUSR2 && SIGUSR2 < KILL_MAX_SIG #ifdef SIGUSR2
[SIGUSR2 ] = "USR2", [SIGUSR2 ] = "USR2",
#endif #endif
#if defined SIGPIPE && SIGPIPE < KILL_MAX_SIG #ifdef SIGPIPE
[SIGPIPE ] = "PIPE", [SIGPIPE ] = "PIPE",
#endif #endif
#if defined SIGALRM && SIGALRM < KILL_MAX_SIG #ifdef SIGALRM
[SIGALRM ] = "ALRM", [SIGALRM ] = "ALRM",
#endif #endif
#if defined SIGTERM && SIGTERM < KILL_MAX_SIG #ifdef SIGTERM
[SIGTERM ] = "TERM", [SIGTERM ] = "TERM",
#endif #endif
#if defined SIGSTKFLT && SIGSTKFLT < KILL_MAX_SIG #ifdef SIGSTKFLT
[SIGSTKFLT] = "STKFLT", [SIGSTKFLT] = "STKFLT",
#endif #endif
#if defined SIGCHLD && SIGCHLD < KILL_MAX_SIG #ifdef SIGCHLD
[SIGCHLD ] = "CHLD", [SIGCHLD ] = "CHLD",
#endif #endif
#if defined SIGCONT && SIGCONT < KILL_MAX_SIG #ifdef SIGCONT
[SIGCONT ] = "CONT", [SIGCONT ] = "CONT",
#endif #endif
#if defined SIGSTOP && SIGSTOP < KILL_MAX_SIG #ifdef SIGSTOP
[SIGSTOP ] = "STOP", [SIGSTOP ] = "STOP",
#endif #endif
#if defined SIGTSTP && SIGTSTP < KILL_MAX_SIG #ifdef SIGTSTP
[SIGTSTP ] = "TSTP", [SIGTSTP ] = "TSTP",
#endif #endif
#if defined SIGTTIN && SIGTTIN < KILL_MAX_SIG #ifdef SIGTTIN
[SIGTTIN ] = "TTIN", [SIGTTIN ] = "TTIN",
#endif #endif
#if defined SIGTTOU && SIGTTOU < KILL_MAX_SIG #ifdef SIGTTOU
[SIGTTOU ] = "TTOU", [SIGTTOU ] = "TTOU",
#endif #endif
#if defined SIGURG && SIGURG < KILL_MAX_SIG #ifdef SIGURG
[SIGURG ] = "URG", [SIGURG ] = "URG",
#endif #endif
#if defined SIGXCPU && SIGXCPU < KILL_MAX_SIG #ifdef SIGXCPU
[SIGXCPU ] = "XCPU", [SIGXCPU ] = "XCPU",
#endif #endif
#if defined SIGXFSZ && SIGXFSZ < KILL_MAX_SIG #ifdef SIGXFSZ
[SIGXFSZ ] = "XFSZ", [SIGXFSZ ] = "XFSZ",
#endif #endif
#if defined SIGVTALRM && SIGVTALRM < KILL_MAX_SIG #ifdef SIGVTALRM
[SIGVTALRM] = "VTALRM", [SIGVTALRM] = "VTALRM",
#endif #endif
#if defined SIGPROF && SIGPROF < KILL_MAX_SIG #ifdef SIGPROF
[SIGPROF ] = "PROF", [SIGPROF ] = "PROF",
#endif #endif
#if defined SIGWINCH && SIGWINCH < KILL_MAX_SIG #ifdef SIGWINCH
[SIGWINCH ] = "WINCH", [SIGWINCH ] = "WINCH",
#endif #endif
#if defined SIGPOLL && SIGPOLL < KILL_MAX_SIG #ifdef SIGPOLL
[SIGPOLL ] = "POLL", [SIGPOLL ] = "POLL",
#endif #endif
#if defined SIGPWR && SIGPWR < KILL_MAX_SIG #ifdef SIGPWR
[SIGPWR ] = "PWR", [SIGPWR ] = "PWR",
#endif #endif
#if defined SIGSYS && SIGSYS < KILL_MAX_SIG #ifdef SIGSYS
[SIGSYS ] = "SYS", [SIGSYS ] = "SYS",
#endif #endif
}; };
@ -133,20 +130,20 @@ int get_signum(const char *name)
return i; return i;
if (strncasecmp(name, "SIG", 3) == 0) if (strncasecmp(name, "SIG", 3) == 0)
name += 3; name += 3;
if (strlen(name) > 6)
return -1;
for (i = 0; i < ARRAY_SIZE(signals); i++) for (i = 0; i < ARRAY_SIZE(signals); i++)
if (strncasecmp(name, signals[i], 6) == 0) if (strcasecmp(name, signals[i]) == 0)
return i; return i;
#if ENABLE_DESKTOP && (defined(SIGIOT) || defined(SIGIO)) #if ENABLE_DESKTOP && (defined(SIGIOT) || defined(SIGIO))
/* These are aliased to other names */ /* SIGIO[T] are aliased to other names,
* thus cannot be stored in the signals[] array.
* Need special code to recognize them */
if ((name[0] | 0x20) == 'i' && (name[1] | 0x20) == 'o') { if ((name[0] | 0x20) == 'i' && (name[1] | 0x20) == 'o') {
#if defined SIGIO #ifdef SIGIO
if (!name[2]) if (!name[2])
return SIGIO; return SIGIO;
#endif #endif
#if defined SIGIOT #ifdef SIGIOT
if ((name[2] | 0x20) == 't' && !name[3]) if ((name[2] | 0x20) == 't' && !name[3])
return SIGIOT; return SIGIOT;
#endif #endif