diff options
author | Rob Landley <rob@landley.net> | 2012-12-23 15:07:28 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2012-12-23 15:07:28 -0600 |
commit | 27cec9ac4ca6c207ea7e74e109e362659f8dfeeb (patch) | |
tree | 612ffcb917683b9132874ba150941479ad4b76cf /toys/lsb/killall.c | |
parent | 41b47485578e8b3ee84bf5f81f76500fa7e02e55 (diff) | |
download | toybox-27cec9ac4ca6c207ea7e74e109e362659f8dfeeb.tar.gz |
Minor cleanups.
Diffstat (limited to 'toys/lsb/killall.c')
-rw-r--r-- | toys/lsb/killall.c | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/toys/lsb/killall.c b/toys/lsb/killall.c index 02a20bea..fe433282 100644 --- a/toys/lsb/killall.c +++ b/toys/lsb/killall.c @@ -10,14 +10,14 @@ config KILLALL bool "killall" default y help - usage: killall [-l] [-qv] [-SIG] PROCESS_NAME... + usage: killall [-l] [-iqv] [-SIG] PROCESS_NAME... Send a signal (default: TERM) to all processes with the given names. - -l print list of all available signals -i ask for confirmation before killing - -v report if the signal was successfully sent + -l print list of all available signals -q don't print any warnings or error messages + -v report if the signal was successfully sent */ #define FOR_killall @@ -34,8 +34,8 @@ static int kill_process(pid_t pid, char *name) if (pid == TT.cur_pid) return 1; - if(toys.optflags & FLAG_i) { - snprintf(toybuf, sizeof(toybuf), "Signal %s(%d) ?", name, pid); + if (toys.optflags & FLAG_i) { + sprintf(toybuf, "Signal %s(%d) ?", name, pid); if (yesno(toybuf, 0) == 0) return 1; } @@ -51,34 +51,27 @@ static int kill_process(pid_t pid, char *name) void killall_main(void) { - char **names; - - if (toys.optflags & FLAG_l) { - sig_to_num(NULL); - return; - } + char **names = toys.optargs; TT.signum = SIGTERM; toys.exitval++; - if (!*toys.optargs) { - toys.exithelp++; - error_exit("Process name missing!"); + if (toys.optflags & FLAG_l) { + sig_to_num(NULL); + return; } - names = toys.optargs; - if (**names == '-') { if (0 > (TT.signum = sig_to_num((*names)+1))) { if (toys.optflags & FLAG_q) exit(1); error_exit("Invalid signal"); } names++; + } - if (!*names) { - toys.exithelp++; - error_exit("Process name missing!"); - } + if (!*names) { + toys.exithelp++; + error_exit("Process name missing!"); } TT.cur_pid = getpid(); |