Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* |
Rob Landley | c9c1a41 | 2006-07-12 19:17:55 +0000 | [diff] [blame] | 3 | * Signal name/number conversion routines. |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 4 | * |
Rob Landley | c9c1a41 | 2006-07-12 19:17:55 +0000 | [diff] [blame] | 5 | * Copyright 2006 Rob Landley <rob@landley.net> |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 6 | * |
Denys Vlasenko | 0ef64bd | 2010-08-16 20:14:46 +0200 | [diff] [blame] | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 8 | */ |
Denys Vlasenko | 2753aae | 2010-12-30 01:17:03 +0100 | [diff] [blame] | 9 | //config:config FEATURE_RTMINMAX |
| 10 | //config: bool "Support RTMIN[+n] and RTMAX[-n] signal names" |
| 11 | //config: default y |
| 12 | //config: help |
Denys Vlasenko | 72089cf | 2017-07-21 09:50:55 +0200 | [diff] [blame] | 13 | //config: Support RTMIN[+n] and RTMAX[-n] signal names |
| 14 | //config: in kill, killall etc. This costs ~250 bytes. |
Rasmus Villemoes | 571e525 | 2018-09-12 16:06:36 +0200 | [diff] [blame] | 15 | //config: |
| 16 | //config:config FEATURE_RTMINMAX_USE_LIBC_DEFINITIONS |
| 17 | //config: bool "Use the definitions of SIGRTMIN/SIGRTMAX provided by libc" |
| 18 | //config: default y |
| 19 | //config: depends on FEATURE_RTMINMAX |
| 20 | //config: help |
| 21 | //config: Some C libraries reserve a few real-time signals for internal |
| 22 | //config: use, and adjust the values of SIGRTMIN/SIGRTMAX seen by |
| 23 | //config: applications accordingly. Saying yes here means that a signal |
| 24 | //config: name RTMIN+n will be interpreted according to the libc definition |
| 25 | //config: of SIGRTMIN, and not the raw definition provided by the kernel. |
| 26 | //config: This behavior matches "kill -l RTMIN+n" from bash. |
Denys Vlasenko | 2753aae | 2010-12-30 01:17:03 +0100 | [diff] [blame] | 27 | |
Bernhard Reutner-Fischer | 421d9e5 | 2006-04-03 16:39:31 +0000 | [diff] [blame] | 28 | #include "libbb.h" |
| 29 | |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 30 | /* Believe it or not, but some arches have more than 32 SIGs! |
| 31 | * HPPA: SIGSTKFLT == 36. */ |
Denis Vlasenko | 5f934b0 | 2007-12-04 10:05:28 +0000 | [diff] [blame] | 32 | |
Denys Vlasenko | 3e134eb | 2016-04-22 18:09:21 +0200 | [diff] [blame] | 33 | static const char signals[][7] ALIGN1 = { |
Rob Landley | c9c1a41 | 2006-07-12 19:17:55 +0000 | [diff] [blame] | 34 | // SUSv3 says kill must support these, and specifies the numerical values, |
| 35 | // http://www.opengroup.org/onlinepubs/009695399/utilities/kill.html |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 36 | // {0, "EXIT"}, {1, "HUP"}, {2, "INT"}, {3, "QUIT"}, |
| 37 | // {6, "ABRT"}, {9, "KILL"}, {14, "ALRM"}, {15, "TERM"} |
Rob Landley | c9c1a41 | 2006-07-12 19:17:55 +0000 | [diff] [blame] | 38 | // And Posix adds the following: |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 39 | // {SIGILL, "ILL"}, {SIGTRAP, "TRAP"}, {SIGFPE, "FPE"}, {SIGUSR1, "USR1"}, |
| 40 | // {SIGSEGV, "SEGV"}, {SIGUSR2, "USR2"}, {SIGPIPE, "PIPE"}, {SIGCHLD, "CHLD"}, |
| 41 | // {SIGCONT, "CONT"}, {SIGSTOP, "STOP"}, {SIGTSTP, "TSTP"}, {SIGTTIN, "TTIN"}, |
| 42 | // {SIGTTOU, "TTOU"} |
Denis Vlasenko | 5f934b0 | 2007-12-04 10:05:28 +0000 | [diff] [blame] | 43 | |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 44 | [0] = "EXIT", |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 45 | #ifdef SIGHUP |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 46 | [SIGHUP ] = "HUP", |
| 47 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 48 | #ifdef SIGINT |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 49 | [SIGINT ] = "INT", |
| 50 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 51 | #ifdef SIGQUIT |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 52 | [SIGQUIT ] = "QUIT", |
| 53 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 54 | #ifdef SIGILL |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 55 | [SIGILL ] = "ILL", |
| 56 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 57 | #ifdef SIGTRAP |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 58 | [SIGTRAP ] = "TRAP", |
| 59 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 60 | #ifdef SIGABRT |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 61 | [SIGABRT ] = "ABRT", |
| 62 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 63 | #ifdef SIGBUS |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 64 | [SIGBUS ] = "BUS", |
| 65 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 66 | #ifdef SIGFPE |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 67 | [SIGFPE ] = "FPE", |
| 68 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 69 | #ifdef SIGKILL |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 70 | [SIGKILL ] = "KILL", |
| 71 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 72 | #ifdef SIGUSR1 |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 73 | [SIGUSR1 ] = "USR1", |
| 74 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 75 | #ifdef SIGSEGV |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 76 | [SIGSEGV ] = "SEGV", |
| 77 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 78 | #ifdef SIGUSR2 |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 79 | [SIGUSR2 ] = "USR2", |
| 80 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 81 | #ifdef SIGPIPE |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 82 | [SIGPIPE ] = "PIPE", |
| 83 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 84 | #ifdef SIGALRM |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 85 | [SIGALRM ] = "ALRM", |
| 86 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 87 | #ifdef SIGTERM |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 88 | [SIGTERM ] = "TERM", |
| 89 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 90 | #ifdef SIGSTKFLT |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 91 | [SIGSTKFLT] = "STKFLT", |
| 92 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 93 | #ifdef SIGCHLD |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 94 | [SIGCHLD ] = "CHLD", |
| 95 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 96 | #ifdef SIGCONT |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 97 | [SIGCONT ] = "CONT", |
| 98 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 99 | #ifdef SIGSTOP |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 100 | [SIGSTOP ] = "STOP", |
| 101 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 102 | #ifdef SIGTSTP |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 103 | [SIGTSTP ] = "TSTP", |
| 104 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 105 | #ifdef SIGTTIN |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 106 | [SIGTTIN ] = "TTIN", |
| 107 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 108 | #ifdef SIGTTOU |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 109 | [SIGTTOU ] = "TTOU", |
| 110 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 111 | #ifdef SIGURG |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 112 | [SIGURG ] = "URG", |
| 113 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 114 | #ifdef SIGXCPU |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 115 | [SIGXCPU ] = "XCPU", |
| 116 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 117 | #ifdef SIGXFSZ |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 118 | [SIGXFSZ ] = "XFSZ", |
| 119 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 120 | #ifdef SIGVTALRM |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 121 | [SIGVTALRM] = "VTALRM", |
| 122 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 123 | #ifdef SIGPROF |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 124 | [SIGPROF ] = "PROF", |
| 125 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 126 | #ifdef SIGWINCH |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 127 | [SIGWINCH ] = "WINCH", |
| 128 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 129 | #ifdef SIGPOLL |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 130 | [SIGPOLL ] = "POLL", |
| 131 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 132 | #ifdef SIGPWR |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 133 | [SIGPWR ] = "PWR", |
| 134 | #endif |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 135 | #ifdef SIGSYS |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 136 | [SIGSYS ] = "SYS", |
| 137 | #endif |
Rasmus Villemoes | 571e525 | 2018-09-12 16:06:36 +0200 | [diff] [blame] | 138 | #if ENABLE_FEATURE_RTMINMAX && !ENABLE_FEATURE_RTMINMAX_USE_LIBC_DEFINITIONS |
Denys Vlasenko | 327d288 | 2011-01-03 13:08:58 +0100 | [diff] [blame] | 139 | # ifdef __SIGRTMIN |
| 140 | [__SIGRTMIN] = "RTMIN", |
| 141 | # endif |
| 142 | // This makes array about x2 bigger. |
| 143 | // More compact approach is to special-case SIGRTMAX in print_signames() |
| 144 | //# ifdef __SIGRTMAX |
| 145 | // [__SIGRTMAX] = "RTMAX", |
| 146 | //# endif |
| 147 | #endif |
Eric Andersen | 842757d | 2001-08-02 05:18:55 +0000 | [diff] [blame] | 148 | }; |
| 149 | |
Rob Landley | c9c1a41 | 2006-07-12 19:17:55 +0000 | [diff] [blame] | 150 | // Convert signal name to number. |
Eric Andersen | 842757d | 2001-08-02 05:18:55 +0000 | [diff] [blame] | 151 | |
Denis Vlasenko | defc1ea | 2008-06-27 02:52:20 +0000 | [diff] [blame] | 152 | int FAST_FUNC get_signum(const char *name) |
Eric Andersen | 842757d | 2001-08-02 05:18:55 +0000 | [diff] [blame] | 153 | { |
Denis Vlasenko | 6b06cb8 | 2008-05-15 21:30:45 +0000 | [diff] [blame] | 154 | unsigned i; |
Eric Andersen | 842757d | 2001-08-02 05:18:55 +0000 | [diff] [blame] | 155 | |
Rasmus Villemoes | 656ca7b | 2018-09-12 16:06:37 +0200 | [diff] [blame] | 156 | /* bb_strtou returns UINT_MAX on error. NSIG is smaller |
| 157 | * than UINT_MAX on any sane Unix. Hence no need |
| 158 | * to check errno after bb_strtou(). |
| 159 | */ |
Denis Vlasenko | 2a813e2 | 2006-12-23 01:06:21 +0000 | [diff] [blame] | 160 | i = bb_strtou(name, NULL, 10); |
Rasmus Villemoes | 656ca7b | 2018-09-12 16:06:37 +0200 | [diff] [blame] | 161 | if (i < NSIG) /* for shells, we allow 0 too */ |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 162 | return i; |
| 163 | if (strncasecmp(name, "SIG", 3) == 0) |
| 164 | name += 3; |
Denis Vlasenko | 6b06cb8 | 2008-05-15 21:30:45 +0000 | [diff] [blame] | 165 | for (i = 0; i < ARRAY_SIZE(signals); i++) |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 166 | if (strcasecmp(name, signals[i]) == 0) |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 167 | return i; |
| 168 | |
Denys Vlasenko | 2753aae | 2010-12-30 01:17:03 +0100 | [diff] [blame] | 169 | #if ENABLE_DESKTOP |
| 170 | # if defined(SIGIOT) || defined(SIGIO) |
Denis Vlasenko | b851c42 | 2007-12-04 21:44:52 +0000 | [diff] [blame] | 171 | /* SIGIO[T] are aliased to other names, |
| 172 | * thus cannot be stored in the signals[] array. |
| 173 | * Need special code to recognize them */ |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 174 | if ((name[0] | 0x20) == 'i' && (name[1] | 0x20) == 'o') { |
Denys Vlasenko | 2753aae | 2010-12-30 01:17:03 +0100 | [diff] [blame] | 175 | # ifdef SIGIO |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 176 | if (!name[2]) |
| 177 | return SIGIO; |
Denys Vlasenko | 2753aae | 2010-12-30 01:17:03 +0100 | [diff] [blame] | 178 | # endif |
| 179 | # ifdef SIGIOT |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 180 | if ((name[2] | 0x20) == 't' && !name[3]) |
| 181 | return SIGIOT; |
Denys Vlasenko | 2753aae | 2010-12-30 01:17:03 +0100 | [diff] [blame] | 182 | # endif |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 183 | } |
Denys Vlasenko | 2753aae | 2010-12-30 01:17:03 +0100 | [diff] [blame] | 184 | # endif |
| 185 | #endif |
| 186 | |
Rasmus Villemoes | 571e525 | 2018-09-12 16:06:36 +0200 | [diff] [blame] | 187 | #if ENABLE_FEATURE_RTMINMAX && defined(SIGRTMIN) && defined(SIGRTMAX) |
| 188 | { |
| 189 | # if ENABLE_FEATURE_RTMINMAX_USE_LIBC_DEFINITIONS |
| 190 | /* Use the libc provided values. */ |
| 191 | unsigned sigrtmin = SIGRTMIN; |
| 192 | unsigned sigrtmax = SIGRTMAX; |
| 193 | # else |
| 194 | /* Use the "raw" SIGRTMIN/MAX. Underscored names, if exist, provide |
| 195 | * them. If they don't exist, fall back to non-underscored ones: */ |
Denys Vlasenko | 7b276fc | 2011-01-03 12:51:13 +0100 | [diff] [blame] | 196 | # if !defined(__SIGRTMIN) |
| 197 | # define __SIGRTMIN SIGRTMIN |
| 198 | # endif |
| 199 | # if !defined(__SIGRTMAX) |
| 200 | # define __SIGRTMAX SIGRTMAX |
| 201 | # endif |
Rasmus Villemoes | 571e525 | 2018-09-12 16:06:36 +0200 | [diff] [blame] | 202 | |
| 203 | # define sigrtmin __SIGRTMIN |
| 204 | # define sigrtmax __SIGRTMAX |
Denys Vlasenko | 2753aae | 2010-12-30 01:17:03 +0100 | [diff] [blame] | 205 | # endif |
Rasmus Villemoes | 571e525 | 2018-09-12 16:06:36 +0200 | [diff] [blame] | 206 | if (strncasecmp(name, "RTMIN", 5) == 0) { |
| 207 | if (!name[5]) |
| 208 | return sigrtmin; |
| 209 | if (name[5] == '+') { |
| 210 | i = bb_strtou(name + 6, NULL, 10); |
Rasmus Villemoes | 656ca7b | 2018-09-12 16:06:37 +0200 | [diff] [blame] | 211 | if (i <= sigrtmax - sigrtmin) |
Rasmus Villemoes | 571e525 | 2018-09-12 16:06:36 +0200 | [diff] [blame] | 212 | return sigrtmin + i; |
| 213 | } |
| 214 | } |
| 215 | else if (strncasecmp(name, "RTMAX", 5) == 0) { |
| 216 | if (!name[5]) |
| 217 | return sigrtmax; |
| 218 | if (name[5] == '-') { |
| 219 | i = bb_strtou(name + 6, NULL, 10); |
Rasmus Villemoes | 656ca7b | 2018-09-12 16:06:37 +0200 | [diff] [blame] | 220 | if (i <= sigrtmax - sigrtmin) |
Rasmus Villemoes | 571e525 | 2018-09-12 16:06:36 +0200 | [diff] [blame] | 221 | return sigrtmax - i; |
| 222 | } |
| 223 | } |
| 224 | # undef sigrtmin |
| 225 | # undef sigrtmax |
| 226 | } |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 227 | #endif |
| 228 | |
Rob Landley | c9c1a41 | 2006-07-12 19:17:55 +0000 | [diff] [blame] | 229 | return -1; |
| 230 | } |
| 231 | |
| 232 | // Convert signal number to name |
| 233 | |
Denis Vlasenko | defc1ea | 2008-06-27 02:52:20 +0000 | [diff] [blame] | 234 | const char* FAST_FUNC get_signame(int number) |
Rob Landley | c9c1a41 | 2006-07-12 19:17:55 +0000 | [diff] [blame] | 235 | { |
Denis Vlasenko | 80b8b39 | 2007-06-25 10:55:35 +0000 | [diff] [blame] | 236 | if ((unsigned)number < ARRAY_SIZE(signals)) { |
Denis Vlasenko | dcf4de2 | 2007-05-01 20:07:29 +0000 | [diff] [blame] | 237 | if (signals[number][0]) /* if it's not an empty str */ |
| 238 | return signals[number]; |
Eric Andersen | 842757d | 2001-08-02 05:18:55 +0000 | [diff] [blame] | 239 | } |
Rob Landley | c9c1a41 | 2006-07-12 19:17:55 +0000 | [diff] [blame] | 240 | |
Denis Vlasenko | 75ab6af | 2007-03-14 21:56:51 +0000 | [diff] [blame] | 241 | return itoa(number); |
Eric Andersen | 842757d | 2001-08-02 05:18:55 +0000 | [diff] [blame] | 242 | } |
Denis Vlasenko | 72e1c89 | 2007-09-29 22:26:01 +0000 | [diff] [blame] | 243 | |
| 244 | |
| 245 | // Print the whole signal list |
| 246 | |
Denis Vlasenko | defc1ea | 2008-06-27 02:52:20 +0000 | [diff] [blame] | 247 | void FAST_FUNC print_signames(void) |
Denis Vlasenko | 72e1c89 | 2007-09-29 22:26:01 +0000 | [diff] [blame] | 248 | { |
Denis Vlasenko | 6b06cb8 | 2008-05-15 21:30:45 +0000 | [diff] [blame] | 249 | unsigned signo; |
Denis Vlasenko | 72e1c89 | 2007-09-29 22:26:01 +0000 | [diff] [blame] | 250 | |
Denis Vlasenko | 6b06cb8 | 2008-05-15 21:30:45 +0000 | [diff] [blame] | 251 | for (signo = 1; signo < ARRAY_SIZE(signals); signo++) { |
Denis Vlasenko | 72e1c89 | 2007-09-29 22:26:01 +0000 | [diff] [blame] | 252 | const char *name = signals[signo]; |
| 253 | if (name[0]) |
Denys Vlasenko | 327d288 | 2011-01-03 13:08:58 +0100 | [diff] [blame] | 254 | printf("%2u) %s\n", signo, name); |
Denis Vlasenko | 72e1c89 | 2007-09-29 22:26:01 +0000 | [diff] [blame] | 255 | } |
Denys Vlasenko | 327d288 | 2011-01-03 13:08:58 +0100 | [diff] [blame] | 256 | #if ENABLE_FEATURE_RTMINMAX |
Rasmus Villemoes | 571e525 | 2018-09-12 16:06:36 +0200 | [diff] [blame] | 257 | # if ENABLE_FEATURE_RTMINMAX_USE_LIBC_DEFINITIONS |
| 258 | # if defined(SIGRTMIN) && defined(SIGRTMAX) |
| 259 | printf("%2u) %s\n", SIGRTMIN, "RTMIN"); |
| 260 | printf("%2u) %s\n", SIGRTMAX, "RTMAX"); |
| 261 | # endif |
| 262 | # else |
| 263 | // __SIGRTMIN is included in signals[] array. |
| 264 | # ifdef __SIGRTMAX |
Denys Vlasenko | 327d288 | 2011-01-03 13:08:58 +0100 | [diff] [blame] | 265 | printf("%2u) %s\n", __SIGRTMAX, "RTMAX"); |
Rasmus Villemoes | 571e525 | 2018-09-12 16:06:36 +0200 | [diff] [blame] | 266 | # endif |
Denys Vlasenko | 327d288 | 2011-01-03 13:08:58 +0100 | [diff] [blame] | 267 | # endif |
| 268 | #endif |
Denis Vlasenko | 72e1c89 | 2007-09-29 22:26:01 +0000 | [diff] [blame] | 269 | } |