diff options
author | Niklas Hambüchen | 2017-10-14 04:31:12 +0200 |
---|---|---|
committer | Niklas Hambüchen | 2017-10-14 04:46:13 +0200 |
commit | 6855f6e80bfe5532d832d2fb9cbcc6628d1d9fca (patch) | |
tree | c33b41aff038f70ea4ff3e44b7b8c35732148bbe /misc-utils/kill.c | |
parent | rfkill: fix typo [coverity scan] (diff) | |
download | kernel-qcow2-util-linux-6855f6e80bfe5532d832d2fb9cbcc6628d1d9fca.tar.gz kernel-qcow2-util-linux-6855f6e80bfe5532d832d2fb9cbcc6628d1d9fca.tar.xz kernel-qcow2-util-linux-6855f6e80bfe5532d832d2fb9cbcc6628d1d9fca.zip |
kill: Extract signal names into signames.h/signames.c
Diffstat (limited to 'misc-utils/kill.c')
-rw-r--r-- | misc-utils/kill.c | 128 |
1 files changed, 1 insertions, 127 deletions
diff --git a/misc-utils/kill.c b/misc-utils/kill.c index 128c092f2..25a3b8874 100644 --- a/misc-utils/kill.c +++ b/misc-utils/kill.c @@ -55,6 +55,7 @@ #include "closestream.h" #include "nls.h" #include "procutils.h" +#include "signames.h" #include "strutils.h" #include "ttyutils.h" #include "xalloc.h" @@ -82,89 +83,6 @@ struct kill_control { verbose:1; }; -static const struct signv { - const char *name; - int val; -} sys_signame[] = { - /* POSIX signals */ - { "HUP", SIGHUP }, /* 1 */ - { "INT", SIGINT }, /* 2 */ - { "QUIT", SIGQUIT }, /* 3 */ - { "ILL", SIGILL }, /* 4 */ -#ifdef SIGTRAP - { "TRAP", SIGTRAP }, /* 5 */ -#endif - { "ABRT", SIGABRT }, /* 6 */ -#ifdef SIGIOT - { "IOT", SIGIOT }, /* 6, same as SIGABRT */ -#endif -#ifdef SIGEMT - { "EMT", SIGEMT }, /* 7 (mips,alpha,sparc*) */ -#endif -#ifdef SIGBUS - { "BUS", SIGBUS }, /* 7 (arm,i386,m68k,ppc), 10 (mips,alpha,sparc*) */ -#endif - { "FPE", SIGFPE }, /* 8 */ - { "KILL", SIGKILL }, /* 9 */ - { "USR1", SIGUSR1 }, /* 10 (arm,i386,m68k,ppc), 30 (alpha,sparc*), 16 (mips) */ - { "SEGV", SIGSEGV }, /* 11 */ - { "USR2", SIGUSR2 }, /* 12 (arm,i386,m68k,ppc), 31 (alpha,sparc*), 17 (mips) */ - { "PIPE", SIGPIPE }, /* 13 */ - { "ALRM", SIGALRM }, /* 14 */ - { "TERM", SIGTERM }, /* 15 */ -#ifdef SIGSTKFLT - { "STKFLT", SIGSTKFLT }, /* 16 (arm,i386,m68k,ppc) */ -#endif - { "CHLD", SIGCHLD }, /* 17 (arm,i386,m68k,ppc), 20 (alpha,sparc*), 18 (mips) */ -#ifdef SIGCLD - { "CLD", SIGCLD }, /* same as SIGCHLD (mips) */ -#endif - { "CONT", SIGCONT }, /* 18 (arm,i386,m68k,ppc), 19 (alpha,sparc*), 25 (mips) */ - { "STOP", SIGSTOP }, /* 19 (arm,i386,m68k,ppc), 17 (alpha,sparc*), 23 (mips) */ - { "TSTP", SIGTSTP }, /* 20 (arm,i386,m68k,ppc), 18 (alpha,sparc*), 24 (mips) */ - { "TTIN", SIGTTIN }, /* 21 (arm,i386,m68k,ppc,alpha,sparc*), 26 (mips) */ - { "TTOU", SIGTTOU }, /* 22 (arm,i386,m68k,ppc,alpha,sparc*), 27 (mips) */ -#ifdef SIGURG - { "URG", SIGURG }, /* 23 (arm,i386,m68k,ppc), 16 (alpha,sparc*), 21 (mips) */ -#endif -#ifdef SIGXCPU - { "XCPU", SIGXCPU }, /* 24 (arm,i386,m68k,ppc,alpha,sparc*), 30 (mips) */ -#endif -#ifdef SIGXFSZ - { "XFSZ", SIGXFSZ }, /* 25 (arm,i386,m68k,ppc,alpha,sparc*), 31 (mips) */ -#endif -#ifdef SIGVTALRM - { "VTALRM", SIGVTALRM }, /* 26 (arm,i386,m68k,ppc,alpha,sparc*), 28 (mips) */ -#endif -#ifdef SIGPROF - { "PROF", SIGPROF }, /* 27 (arm,i386,m68k,ppc,alpha,sparc*), 29 (mips) */ -#endif -#ifdef SIGWINCH - { "WINCH", SIGWINCH }, /* 28 (arm,i386,m68k,ppc,alpha,sparc*), 20 (mips) */ -#endif -#ifdef SIGIO - { "IO", SIGIO }, /* 29 (arm,i386,m68k,ppc), 23 (alpha,sparc*), 22 (mips) */ -#endif -#ifdef SIGPOLL - { "POLL", SIGPOLL }, /* same as SIGIO */ -#endif -#ifdef SIGINFO - { "INFO", SIGINFO }, /* 29 (alpha) */ -#endif -#ifdef SIGLOST - { "LOST", SIGLOST }, /* 29 (arm,i386,m68k,ppc,sparc*) */ -#endif -#ifdef SIGPWR - { "PWR", SIGPWR }, /* 30 (arm,i386,m68k,ppc), 29 (alpha,sparc*), 19 (mips) */ -#endif -#ifdef SIGUNUSED - { "UNUSED", SIGUNUSED }, /* 31 (arm,i386,m68k,ppc) */ -#endif -#ifdef SIGSYS - { "SYS", SIGSYS }, /* 31 (mips,alpha,sparc*) */ -#endif -}; - static void print_signal_name(int signum) { size_t n; @@ -236,50 +154,6 @@ static void err_nosig(char *name) exit(EXIT_FAILURE); } -#ifdef SIGRTMIN -static int rtsig_to_signum(char *sig) -{ - int num, maxi = 0; - char *ep = NULL; - - if (strncasecmp(sig, "min+", 4) == 0) - sig += 4; - else if (strncasecmp(sig, "max-", 4) == 0) { - sig += 4; - maxi = 1; - } - if (!isdigit(*sig)) - return -1; - errno = 0; - num = strtol(sig, &ep, 10); - if (!ep || sig == ep || errno || num < 0) - return -1; - num = maxi ? SIGRTMAX - num : SIGRTMIN + num; - if (num < SIGRTMIN || SIGRTMAX < num) - return -1; - return num; -} -#endif - -static int signame_to_signum(char *sig) -{ - size_t n; - - if (!strncasecmp(sig, "sig", 3)) - sig += 3; -#ifdef SIGRTMIN - /* RT signals */ - if (!strncasecmp(sig, "rt", 2)) - return rtsig_to_signum(sig + 2); -#endif - /* Normal signals */ - for (n = 0; n < ARRAY_SIZE(sys_signame); n++) { - if (!strcasecmp(sys_signame[n].name, sig)) - return sys_signame[n].val; - } - return -1; -} - static int arg_to_signum(char *arg, int maskbit) { int numsig; |