diff options
author | Rob Landley <rob@landley.net> | 2012-02-26 13:48:00 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2012-02-26 13:48:00 -0600 |
commit | 2dd50adc460e63c57eddb696f908dd6b1abfd723 (patch) | |
tree | fe0a05588e4d8c2485cdba1113b213442693d92d /toys/killall.c | |
parent | bef57ed266cfad82114b5bb16052571035e9fff1 (diff) | |
download | toybox-2dd50adc460e63c57eddb696f908dd6b1abfd723.tar.gz |
Factor out common code between killall/kill and move it to lib/lib.c, plus cleanups on kill.c.
Diffstat (limited to 'toys/killall.c')
-rw-r--r-- | toys/killall.c | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/toys/killall.c b/toys/killall.c index 44379833..b4e06944 100644 --- a/toys/killall.c +++ b/toys/killall.c @@ -30,44 +30,6 @@ DEFINE_GLOBALS( ) #define TT this.killall -struct signame { - int num; - char *name; -}; - -// Signals required by POSIX 2008: -// http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html - -#define SIGNIFY(x) {SIG##x, #x} - -static struct signame signames[] = { - SIGNIFY(ABRT), SIGNIFY(ALRM), SIGNIFY(BUS), SIGNIFY(CHLD), SIGNIFY(CONT), - SIGNIFY(FPE), SIGNIFY(HUP), SIGNIFY(ILL), SIGNIFY(INT), SIGNIFY(KILL), - SIGNIFY(PIPE), SIGNIFY(QUIT), SIGNIFY(SEGV), SIGNIFY(STOP), SIGNIFY(TERM), - SIGNIFY(TSTP), SIGNIFY(TTIN), SIGNIFY(TTOU), SIGNIFY(USR1), SIGNIFY(USR2), - SIGNIFY(SYS), SIGNIFY(TRAP), SIGNIFY(URG), SIGNIFY(VTALRM), SIGNIFY(XCPU), - SIGNIFY(XFSZ) -}; - -// SIGNIFY(STKFLT), SIGNIFY(WINCH), SIGNIFY(IO), SIGNIFY(PWR) - -// Convert name to signal number. If name == NULL print names. -static int sig_to_num(char *pidstr) -{ - int i; - - if (pidstr) { - if (isdigit(*pidstr)) return atol(pidstr); - if (!strncasecmp(pidstr, "sig", 3)) pidstr+=3; - } - for (i = 0; i < sizeof(signames)/sizeof(struct signame); i++) - if (!pidstr) xputs(signames[i].name); - else if (!strcasecmp(pidstr, signames[i].name)) - return signames[i].num; - - return -1; -} - static void kill_process(pid_t pid) { int ret; |