Date: Mon, 9 Dec 2002 06:01:23 +1100 (EST) From: stacey <duqz@starwhack.net> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/46107: killall(1) can prematurely kill itself Message-ID: <200212081901.gB8J1MIn021594@starwhack.net>
next in thread | raw e-mail | index | archive | help
>Number: 46107
>Category: bin
>Synopsis: killall(1) can prematurely kill itself
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sun Dec 08 11:10:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: stacey <duqz@starwhack.net>
>Release: FreeBSD 4.7-STABLE i386
>Organization:
>Environment:
System: FreeBSD starwhack.net 4.7-STABLE FreeBSD 4.7-STABLE #5: Sun Dec 1 18:37:27 EST 2002 root@starwhack.net:/usr/obj/usr/src/sys/STARWHACK i386
>Description:
killall(1) suicides, which makes it die before killing other matching procs.
>How-To-Repeat:
$ ps | grep killall
21470 p1 T 0:00.07 killall ducks
21473 p1 T 0:00.05 killall go
21475 p1 T 0:00.04 killall wak wak
21483 p1 R+ 0:00.06 grep killall
$ killall -KILL -v killall
kill -KILL 21551
Killed
>Fix:
Index: killall.c
===================================================================
RCS file: /home/stacey_/src/freebsd/src/usr.bin/killall/killall.c,v
retrieving revision 1.19
diff -u -r1.19 killall.c
--- killall.c 30 Jun 2002 05:25:01 -0000 1.19
+++ killall.c 8 Dec 2002 18:03:18 -0000
@@ -117,6 +117,7 @@
int zflag = 0;
uid_t uid = 0;
dev_t tdev = 0;
+ pid_t mypid;
char thiscmd[MAXCOMLEN + 1];
pid_t thispid;
uid_t thisuid;
@@ -289,6 +290,7 @@
nprocs = size / sizeof(struct kinfo_proc);
if (dflag)
printf("nprocs %d\n", nprocs);
+ mypid = getpid();
for (i = 0; i < nprocs; i++) {
if ((procs[i].ki_stat & SZOMB) == SZOMB && !zflag)
@@ -365,7 +367,7 @@
thispid);
killed++;
- if (!dflag && !sflag) {
+ if (!dflag && !sflag && thispid != mypid) {
if (kill(thispid, sig) < 0 /* && errno != ESRCH */ ) {
warn("warning: kill -%s %d",
upper(sys_signame[sig]), thispid);
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200212081901.gB8J1MIn021594>
