From 41b47485578e8b3ee84bf5f81f76500fa7e02e55 Mon Sep 17 00:00:00 2001 From: Elie De Brauwer Date: Sun, 16 Dec 2012 16:51:30 +0100 Subject: LSB does not allow killall to kill itself --- toys/lsb/killall.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 @@ -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"); -- cgit v1.2.3