diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-09-30 02:26:01 +0400 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-09-30 02:26:01 +0400 |
commit | 72e1c89d971aa2e37abf705c6a01f002deac09b8 (patch) | |
tree | 6edb25e260701f9f6e49769e4bb7e31e7e2e6063 /procps/kill.c | |
parent | 2450e4ba44707a64920ea6c9276930a1210e76cc (diff) |
pgrep,pkill: new applets by Loic Grenie <loic.grenie@gmail.com>
Diffstat (limited to 'procps/kill.c')
-rw-r--r-- | procps/kill.c | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/procps/kill.c b/procps/kill.c index 892a798c5..961f8cb14 100644 --- a/procps/kill.c +++ b/procps/kill.c @@ -58,33 +58,29 @@ int kill_main(int argc, char **argv) if (arg[1] == 'l' && arg[2] == '\0') { if (argc == 1) { /* Print the whole signal list */ - for (signo = 1; signo < 32; signo++) { - const char *name = get_signame(signo); - if (!isdigit(name[0])) - puts(name); - } - } else { /* -l <sig list> */ - while ((arg = *++argv)) { - if (isdigit(arg[0])) { - signo = bb_strtou(arg, NULL, 10); - if (errno) { - bb_error_msg("unknown signal '%s'", arg); - return EXIT_FAILURE; - } - /* Exitcodes >= 0x80 are to be treated - * as "killed by signal (exitcode & 0x7f)" */ - puts(get_signame(signo & 0x7f)); - /* TODO: 'bad' signal# - coreutils says: - * kill: 127: invalid signal - * we just print "127" instead */ - } else { - signo = get_signum(arg); - if (signo < 0) { - bb_error_msg("unknown signal '%s'", arg); - return EXIT_FAILURE; - } - printf("%d\n", signo); + print_signames_and_exit(); + } + /* -l <sig list> */ + while ((arg = *++argv)) { + if (isdigit(arg[0])) { + signo = bb_strtou(arg, NULL, 10); + if (errno) { + bb_error_msg("unknown signal '%s'", arg); + return EXIT_FAILURE; + } + /* Exitcodes >= 0x80 are to be treated + * as "killed by signal (exitcode & 0x7f)" */ + puts(get_signame(signo & 0x7f)); + /* TODO: 'bad' signal# - coreutils says: + * kill: 127: invalid signal + * we just print "127" instead */ + } else { + signo = get_signum(arg); + if (signo < 0) { + bb_error_msg("unknown signal '%s'", arg); + return EXIT_FAILURE; } + printf("%d\n", signo); } } /* If they specified -l, we are all done */ |