aboutsummaryrefslogtreecommitdiff
path: root/toys/lsb
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2019-07-01 16:15:55 -0700
committerRob Landley <rob@landley.net>2019-07-06 16:15:35 -0500
commit82a33b3f060e163b14155e8f6833ec30514a609b (patch)
tree8ea5cce41b024233ef8af23dcaf12a1068e9b0be /toys/lsb
parent3d8bbdc83d8b4891c1b887942e054974eb6291b7 (diff)
downloadtoybox-82a33b3f060e163b14155e8f6833ec30514a609b.tar.gz
killall: better handling of long names.
Change names_to_pid() so that we can actually match shell scripts with long names (the code to get the shell script's name was correct, but there was an extra test preventing us from actually comparing it to the sought name). In kill.c itself, remove a dead test for -l and switch to the FLAG() macro. Also extend the tests to explicitly cover long and short names.
Diffstat (limited to 'toys/lsb')
-rw-r--r--toys/lsb/killall.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/toys/lsb/killall.c b/toys/lsb/killall.c
index 119e01fa..47aea23d 100644
--- a/toys/lsb/killall.c
+++ b/toys/lsb/killall.c
@@ -39,7 +39,7 @@ static int kill_process(pid_t pid, char *name)
if (pid == TT.cur_pid) return 0;
- if (toys.optflags & FLAG_i) {
+ if (FLAG(i)) {
fprintf(stderr, "Signal %s(%d)", name, (int)pid);
if (!yesno(0)) return 0;
}
@@ -53,8 +53,8 @@ static int kill_process(pid_t pid, char *name)
} else offset++;
}
if (errno) {
- if (!(toys.optflags & FLAG_q)) perror_msg("pid %d", (int)pid);
- } else if (toys.optflags & FLAG_v)
+ if (!FLAG(q)) perror_msg("pid %d", (int)pid);
+ } else if (FLAG(v))
printf("Killed %s(%d) with signal %d\n", name, pid, TT.signum);
return 0;
@@ -67,14 +67,14 @@ void killall_main(void)
TT.names = toys.optargs;
TT.signum = SIGTERM;
- if (toys.optflags & FLAG_l) {
+ if (FLAG(l)) {
list_signals();
return;
}
if (TT.s || (*TT.names && **TT.names == '-')) {
if (0 > (TT.signum = sig_to_num(TT.s ? TT.s : (*TT.names)+1))) {
- if (toys.optflags & FLAG_q) exit(1);
+ if (FLAG(q)) exit(1);
error_exit("Invalid signal");
}
if (!TT.s) {
@@ -83,7 +83,7 @@ void killall_main(void)
}
}
- if (!(toys.optflags & FLAG_l) && !toys.optc) help_exit("no name");
+ if (!toys.optc) help_exit("no name");
TT.cur_pid = getpid();