diff options
author | Elie De Brauwer <eliedebrauwer@gmail.com> | 2012-12-16 16:51:30 +0100 |
---|---|---|
committer | Elie De Brauwer <eliedebrauwer@gmail.com> | 2012-12-16 16:51:30 +0100 |
commit | 41b47485578e8b3ee84bf5f81f76500fa7e02e55 (patch) | |
tree | 79ec27e9f4beb3fa85dacc65dd448b04b3d1286a | |
parent | e5af216104c71b817b7000a09942dbabc468c1d7 (diff) | |
download | toybox-41b47485578e8b3ee84bf5f81f76500fa7e02e55.tar.gz |
LSB does not allow killall to kill itself
-rw-r--r-- | toys/lsb/killall.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/toys/lsb/killall.c b/toys/lsb/killall.c index 655ed734..02a20bea 100644 --- a/toys/lsb/killall.c +++ b/toys/lsb/killall.c @@ -1,4 +1,3 @@ - /* killall.c - Send signal (default: TERM) to all processes with given names. * * Copyright 2012 Andreas Heck <aheck@gmx.de> @@ -26,12 +25,15 @@ config KILLALL GLOBALS( int signum; + pid_t cur_pid; ) static int kill_process(pid_t pid, char *name) { int ret; + if (pid == TT.cur_pid) return 1; + if(toys.optflags & FLAG_i) { snprintf(toybuf, sizeof(toybuf), "Signal %s(%d) ?", name, pid); if (yesno(toybuf, 0) == 0) return 1; @@ -79,6 +81,8 @@ void killall_main(void) } } + TT.cur_pid = getpid(); + for_each_pid_with_name_in(names, kill_process); if (toys.exitval && !(toys.optflags & FLAG_q)) error_exit("No such process"); |