Mercurial > hg > toybox
changeset 1154:f7b777035025 draft
Add -s option, allow zero optargs for -l. (Suggested by Ashwini Sharma.)
author | Rob Landley <rob@landley.net> |
---|---|
date | Sun, 22 Dec 2013 19:39:12 -0600 |
parents | c4ac6a90963d |
children | 63f8c7fa94d7 |
files | toys/lsb/killall.c |
diffstat | 1 files changed, 12 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/toys/lsb/killall.c Sun Dec 22 15:48:44 2013 -0600 +++ b/toys/lsb/killall.c Sun Dec 22 19:39:12 2013 -0600 @@ -4,19 +4,20 @@ * * http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/killall.html -USE_KILLALL(NEWTOY(killall, "<1?lqvi", TOYFLAG_USR|TOYFLAG_BIN)) +USE_KILLALL(NEWTOY(killall, "?s:lqvi", TOYFLAG_USR|TOYFLAG_BIN)) config KILLALL bool "killall" default y help - usage: killall [-l] [-iqv] [-SIG] PROCESS_NAME... + usage: killall [-l] [-iqv] [-SIGNAL|-s SIGNAL] PROCESS_NAME... Send a signal (default: TERM) to all processes with the given names. -i ask for confirmation before killing -l print list of all available signals -q don't print any warnings or error messages + -s send SIGNAL instead of SIGTERM -v report if the signal was successfully sent */ @@ -24,6 +25,8 @@ #include "toys.h" GLOBALS( + char *sig; + int signum; pid_t cur_pid; char **names; @@ -69,16 +72,18 @@ return; } - if (**TT.names == '-') { - if (0 > (TT.signum = sig_to_num((*TT.names)+1))) { + if (TT.sig || **TT.names == '-') { + if (0 > (TT.signum = sig_to_num(TT.sig ? TT.sig : (*TT.names)+1))) { if (toys.optflags & FLAG_q) exit(1); error_exit("Invalid signal"); } - TT.names++; - toys.optc--; + if (!TT.sig) { + TT.names++; + toys.optc--; + } } - if (!toys.optc) { + if (!(toys.optflags & FLAG_l) && !toys.optc) { toys.exithelp++; error_exit("no name"); }