aboutsummaryrefslogtreecommitdiff
path: root/toys/lsb
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2013-12-22 19:39:12 -0600
committerRob Landley <rob@landley.net>2013-12-22 19:39:12 -0600
commitf070ec01d918ff0474a0a5fc9aa745fcd848622a (patch)
tree50fb381912926c7c74c289e173f59c35505a5ff4 /toys/lsb
parentd10f39dcd08bf42b2e63789b15966ed908ff6439 (diff)
downloadtoybox-f070ec01d918ff0474a0a5fc9aa745fcd848622a.tar.gz
Add -s option, allow zero optargs for -l. (Suggested by Ashwini Sharma.)
Diffstat (limited to 'toys/lsb')
-rw-r--r--toys/lsb/killall.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/toys/lsb/killall.c b/toys/lsb/killall.c
index 0f96c31f..e01757a0 100644
--- a/toys/lsb/killall.c
+++ b/toys/lsb/killall.c
@@ -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 @@ config KILLALL
#include "toys.h"
GLOBALS(
+ char *sig;
+
int signum;
pid_t cur_pid;
char **names;
@@ -69,16 +72,18 @@ void killall_main(void)
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");
}