lineedit: do not hang on error, but return error indicator.
[oweals/busybox.git] / libbb / u_signal_names.c
index ed3bb5c5bdb1a6275dd369b51ad0393e4113342d..9263859f52998f96b69a2b7308a78d31358934d4 100644 (file)
@@ -4,15 +4,17 @@
  *
  * Copyright 2006 Rob Landley <rob@landley.net>
  *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  */
 
 #include "libbb.h"
 
-static const char signals[32][7] = {
+/* Believe it or not, but some arches have more than 32 SIGs!
+ * HPPA: SIGSTKFLT == 36. */
+
+static const char signals[][7] = {
        // SUSv3 says kill must support these, and specifies the numerical values,
        // http://www.opengroup.org/onlinepubs/009695399/utilities/kill.html
-       // 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:
@@ -20,6 +22,7 @@ static const char signals[32][7] = {
        // {SIGSEGV, "SEGV"}, {SIGUSR2, "USR2"}, {SIGPIPE, "PIPE"}, {SIGCHLD, "CHLD"},
        // {SIGCONT, "CONT"}, {SIGSTOP, "STOP"}, {SIGTSTP, "TSTP"}, {SIGTTIN, "TTIN"},
        // {SIGTTOU, "TTOU"}
+
        [0] = "EXIT",
 #ifdef SIGHUP
        [SIGHUP   ] = "HUP",
@@ -118,9 +121,9 @@ static const char signals[32][7] = {
 
 // Convert signal name to number.
 
-int get_signum(const char *name)
+int FAST_FUNC get_signum(const char *name)
 {
-       int i;
+       unsigned i;
 
        i = bb_strtou(name, NULL, 10);
        if (!errno)
@@ -132,7 +135,9 @@ int get_signum(const char *name)
                        return i;
 
 #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') {
 #ifdef SIGIO
                if (!name[2])
@@ -150,7 +155,7 @@ int get_signum(const char *name)
 
 // Convert signal number to name
 
-const char *get_signame(int number)
+const char* FAST_FUNC get_signame(int number)
 {
        if ((unsigned)number < ARRAY_SIZE(signals)) {
                if (signals[number][0]) /* if it's not an empty str */
@@ -163,9 +168,9 @@ const char *get_signame(int number)
 
 // Print the whole signal list
 
-void print_signames(void)
+void FAST_FUNC print_signames(void)
 {
-       int signo;
+       unsigned signo;
 
        for (signo = 1; signo < ARRAY_SIZE(signals); signo++) {
                const char *name = signals[signo];