# HG changeset patch # User Elie De Brauwer # Date 1355673090 -3600 # Node ID 5d435b48da8def8bd714c8e1aa71215e28620201 # Parent e2e99fa861e96fb3705ff73eca590f969e802596 LSB does not allow killall to kill itself diff -r e2e99fa861e9 -r 5d435b48da8d toys/lsb/killall.c --- a/toys/lsb/killall.c Sun Dec 23 14:06:17 2012 -0600 +++ b/toys/lsb/killall.c Sun Dec 16 16:51:30 2012 +0100 @@ -1,4 +1,3 @@ - /* killall.c - Send signal (default: TERM) to all processes with given names. * * Copyright 2012 Andreas Heck @@ -26,12 +25,15 @@ 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 @@ } } + 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");