All,
In my previous patch, the pif shouldn't be stored inside the GLOBAL(),
it should be just a regular global variable. In attach a patch which
corrects this.
gr
E.
On 12/16/2012 04:54 PM, Elie De Brauwer wrote:
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 1355677927 -3600
# Node ID 32b9b7febf4f1e0378acfb3f7e50048032fb917b
# Parent 1c633889c678b3cf894bf70e02ce1eb42d5010fd
LSB does not allow killall to kill itself
diff -r 1c633889c678 -r 32b9b7febf4f 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 18:12:07 2012 +0100
@@ -28,10 +28,15 @@
int signum;
)
+pid_t cur_pid;
+
+
static int kill_process(pid_t pid, char *name)
{
int ret;
+ if (pid == 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 +84,8 @@
}
}
+ 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