Hi all,
The LSB specification of killall says "A killall process never kills
itself (but may kill other killall processes)."
The current implementation of killall does not adhere to this rule, with
the patch in attach killall will adhere to this rule.
Before:
edb@lapedb:~/edb-stuff/toybox/toybox$ ./toybox killall -9 toybox
Killed
After:
edb@lapedb:~/edb-stuff/toybox/toybox$ ./toybox killall -9 toybox
killall: No such process
Note: this patch should be applied after my previous submission, if for
some reason the previous path is unwanted let me know and I'll resubmit
this one.
my 2 cents
E.
--
Elie De Brauwer
# HG changeset patch
# User Elie De Brauwer <[email protected]>
# Date 1355673090 -3600
# Node ID ed4c52a2f9b96a7484a5258913e357722a7012d8
# Parent ad5653b98b4d03b1c2c156a8906f2e6c57fdfe56
LSB does not allow killall to kill itself
diff -r ad5653b98b4d -r ed4c52a2f9b9 toys/lsb/killall.c
--- a/toys/lsb/killall.c Sun Dec 16 13:43:36 2012 +0100
+++ b/toys/lsb/killall.c Sun Dec 16 16:51:30 2012 +0100
@@ -26,12 +26,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 +82,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");
_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net