aboutsummaryrefslogtreecommitdiff
path: root/procps/kill.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-09-29 22:26:01 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-09-29 22:26:01 +0000
commit72e1c89d971aa2e37abf705c6a01f002deac09b8 (patch)
tree6edb25e260701f9f6e49769e4bb7e31e7e2e6063 /procps/kill.c
parent2450e4ba44707a64920ea6c9276930a1210e76cc (diff)
downloadbusybox-w32-72e1c89d971aa2e37abf705c6a01f002deac09b8.tar.gz
busybox-w32-72e1c89d971aa2e37abf705c6a01f002deac09b8.tar.bz2
busybox-w32-72e1c89d971aa2e37abf705c6a01f002deac09b8.zip
pgrep,pkill: new applets by Loic Grenie <loic.grenie@gmail.com>
Diffstat (limited to 'procps/kill.c')
-rw-r--r--procps/kill.c48
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)
58 if (arg[1] == 'l' && arg[2] == '\0') { 58 if (arg[1] == 'l' && arg[2] == '\0') {
59 if (argc == 1) { 59 if (argc == 1) {
60 /* Print the whole signal list */ 60 /* Print the whole signal list */
61 for (signo = 1; signo < 32; signo++) { 61 print_signames_and_exit();
62 const char *name = get_signame(signo); 62 }
63 if (!isdigit(name[0])) 63 /* -l <sig list> */
64 puts(name); 64 while ((arg = *++argv)) {
65 } 65 if (isdigit(arg[0])) {
66 } else { /* -l <sig list> */ 66 signo = bb_strtou(arg, NULL, 10);
67 while ((arg = *++argv)) { 67 if (errno) {
68 if (isdigit(arg[0])) { 68 bb_error_msg("unknown signal '%s'", arg);
69 signo = bb_strtou(arg, NULL, 10); 69 return EXIT_FAILURE;
70 if (errno) { 70 }
71 bb_error_msg("unknown signal '%s'", arg); 71 /* Exitcodes >= 0x80 are to be treated
72 return EXIT_FAILURE; 72 * as "killed by signal (exitcode & 0x7f)" */
73 } 73 puts(get_signame(signo & 0x7f));
74 /* Exitcodes >= 0x80 are to be treated 74 /* TODO: 'bad' signal# - coreutils says:
75 * as "killed by signal (exitcode & 0x7f)" */ 75 * kill: 127: invalid signal
76 puts(get_signame(signo & 0x7f)); 76 * we just print "127" instead */
77 /* TODO: 'bad' signal# - coreutils says: 77 } else {
78 * kill: 127: invalid signal 78 signo = get_signum(arg);
79 * we just print "127" instead */ 79 if (signo < 0) {
80 } else { 80 bb_error_msg("unknown signal '%s'", arg);
81 signo = get_signum(arg); 81 return EXIT_FAILURE;
82 if (signo < 0) {
83 bb_error_msg("unknown signal '%s'", arg);
84 return EXIT_FAILURE;
85 }
86 printf("%d\n", signo);
87 } 82 }
83 printf("%d\n", signo);
88 } 84 }
89 } 85 }
90 /* If they specified -l, we are all done */ 86 /* If they specified -l, we are all done */