From aac26a1826da28175b40d5910eab414b7ea61f9d Mon Sep 17 00:00:00 2001
From: Mike Pechkin <mpech@cvs.openbsd.org>
Date: Thu, 15 Jul 2004 13:55:11 +0000
Subject: Skip SYSTEM and ourown proccess on every loop.

millert@, otto@
---
 usr.bin/pkill/pkill.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

(limited to 'usr.bin')

diff --git a/usr.bin/pkill/pkill.c b/usr.bin/pkill/pkill.c
index e1cd68fc0c3..fadfdefc3b1 100644
--- a/usr.bin/pkill/pkill.c
+++ b/usr.bin/pkill/pkill.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: pkill.c,v 1.4 2004/06/24 18:04:45 millert Exp $	*/
+/*	$OpenBSD: pkill.c,v 1.5 2004/07/15 13:55:10 mpech Exp $	*/
 /*	$NetBSD: pkill.c,v 1.5 2002/10/27 11:49:34 kleink Exp $	*/
 
 /*-
@@ -38,7 +38,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$OpenBSD: pkill.c,v 1.4 2004/06/24 18:04:45 millert Exp $";
+static const char rcsid[] = "$OpenBSD: pkill.c,v 1.5 2004/07/15 13:55:10 mpech Exp $";
 #endif /* !lint */
 
 #include <sys/types.h>
@@ -291,7 +291,7 @@ main(int argc, char **argv)
 	}
 
 	for (i = 0, kp = plist; i < nproc; i++, kp++) {
-		if ((kp->p_flag & P_SYSTEM) != 0)
+		if ((kp->p_flag & P_SYSTEM) != 0 || kp->p_pid == mypid)
 			continue;
 
 		SLIST_FOREACH(li, &ruidlist, li_chain)
@@ -385,7 +385,7 @@ main(int argc, char **argv)
 	 * Take the appropriate action for each matched process, if any.
 	 */
 	for (i = 0, rv = STATUS_NOMATCH, kp = plist; i < nproc; i++, kp++) {
-		if (kp->p_pid == mypid)
+		if ((kp->p_flag & P_SYSTEM) != 0 || kp->p_pid == mypid)
 			continue;
 		if (selected[i]) {
 			if (inverse)
@@ -393,9 +393,6 @@ main(int argc, char **argv)
 		} else if (!inverse)
 			continue;
 
-		if ((kp->p_flag & P_SYSTEM) != 0)
-			continue;
-
 		if ((*action)(kp) == -1)
 			rv = STATUS_ERROR;
 		else if (rv != STATUS_ERROR)
-- 
cgit v1.2.3