DragonFly BSD
DragonFly submit List (threaded) for 2004-01
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

suicide prevention patch for killall(1)


From: Chris Pressey <cpressey@xxxxxxxxxxxxxxx>
Date: Fri, 23 Jan 2004 10:09:48 -0800

Hm, OK, I have to ponder the mount thing a little.

In the meantime, here is a patch to killall that stops it from
committing suicide.  Backported from FreeBSD:

  http://www.freebsd.org/cgi/query-pr.cgi?pr=46107

Not well tested (I *really* need an adequately-size harddrive for
playing around with DragonFly on!) but it looks pretty straightforward.

-Chris

--- killall.c.orig	Fri Jan 23 09:36:13 2004
+++ killall.c	Fri Jan 23 09:35:36 2004
@@ -116,6 +116,7 @@
 	int		mflag = 0;
 	uid_t		uid = 0;
 	dev_t		tdev = 0;
+	pid_t		mypid;
 	char		thiscmd[MAXCOMLEN + 1];
 	pid_t		thispid;
 	uid_t		thisuid;
@@ -285,6 +286,7 @@
 	nprocs = size / sizeof(struct kinfo_proc);
 	if (dflag)
 		printf("nprocs %d\n", nprocs);
+	mypid = getpid();
 
 	for (i = 0; i < nprocs; i++) {
 		thispid = procs[i].kp_proc.p_pid;
@@ -293,6 +295,8 @@
 		thistdev = procs[i].kp_eproc.e_tdev;
 		thisuid = procs[i].kp_eproc.e_ucred.cr_ruid;	/* real uid */
 
+		if (thispid == mypid)
+			continue;
 		matched = 1;
 		if ((int)procs[i].kp_proc.p_pid < 0)
 			matched = 0;


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]