diff options
author | Eric Andersen <andersen@codepoet.org> | 1999-10-23 05:42:08 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 1999-10-23 05:42:08 +0000 |
commit | a709317cea0180772616152d2f1af195a95703fd (patch) | |
tree | c9b53fa236820a0bdb28cb3f531b0710f9807546 /procps | |
parent | a07f0b040808c7b1a3b81cbbe3a580f023450817 (diff) | |
download | busybox-a709317cea0180772616152d2f1af195a95703fd.tar.gz |
More stuff
Diffstat (limited to 'procps')
-rw-r--r-- | procps/kill.c | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/procps/kill.c b/procps/kill.c index 2fabf56d2..8cc2b044e 100644 --- a/procps/kill.c +++ b/procps/kill.c @@ -25,6 +25,7 @@ #include <stdlib.h> #include <unistd.h> #include <signal.h> +#include <ctype.h> const char kill_usage[] = "kill [-signal] process-id [process-id ...]\n"; @@ -112,47 +113,47 @@ const struct signal_name signames[] = { extern int kill_main (int argc, char **argv) { - int had_error = 0; int sig = SIGTERM; + if ( argc < 2 ) + usage (kill_usage); - - if (argv[1][0] == '-') { - if (argv[1][1] >= '0' && argv[1][1] <= '9') { - sig = atoi (&argv[1][1]); + if ( **(argv+1) == '-' ) { + if (isdigit( *(*(++argv)+1) )) { + sig = atoi (*argv); if (sig < 0 || sig >= NSIG) goto end; - } else { + } + else { const struct signal_name *s = signames; - for (;;) { - if (strcmp (s->name, &argv[1][1]) == 0) { + while (s->name != 0) { + if (strcasecmp (s->name, *argv+1) == 0) { sig = s->number; break; } s++; - if (s->name == 0) - goto end; } + if (s->name == 0) + goto end; } - argv++; - argc--; - } - while (argc > 1) { + + while (--argc > 1) { int pid; - if (argv[1][0] < '0' || argv[1][0] > '9') - goto end; - pid = atoi (argv[1]); + if (! isdigit( **(++argv))) { + fprintf(stderr, "bad PID: %s\n", *argv); + exit( FALSE); + } + pid = atoi (*argv); if (kill (pid, sig) != 0) { - had_error = 1; - perror (argv[1]); + perror (*argv); + exit ( FALSE); } - argv++; - argc--; } - if (had_error) { + end: - usage (kill_usage); - } + fprintf(stderr, "bad signal name: %s\n", *argv); exit (TRUE); } + + |