diff options
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 */ |