Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 Nov 2013 05:22:29 +0000 (UTC)
From:      Eitan Adler <eadler@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r257911 - head/bin/pkill
Message-ID:  <201311100522.rAA5MTsf009249@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: eadler
Date: Sun Nov 10 05:22:29 2013
New Revision: 257911
URL: http://svnweb.freebsd.org/changeset/base/257911

Log:
  pkill - Optimize pgrep -F
  
   Ask for a specific process instead of pulling down all processes when
   -F <pidfile> is specified.  This is much much faster.
  
   Obtained from:	DragonflyBSD

Modified:
  head/bin/pkill/pkill.c

Modified: head/bin/pkill/pkill.c
==============================================================================
--- head/bin/pkill/pkill.c	Sun Nov 10 04:22:40 2013	(r257910)
+++ head/bin/pkill/pkill.c	Sun Nov 10 05:22:29 2013	(r257911)
@@ -318,7 +318,10 @@ main(int argc, char **argv)
 	 * Use KERN_PROC_PROC instead of KERN_PROC_ALL, since we
 	 * just want processes and not individual kernel threads.
 	 */
-	plist = kvm_getprocs(kd, KERN_PROC_PROC, 0, &nproc);
+	if (pidfromfile >= 0)
+		plist = kvm_getprocs(kd, KERN_PROC_PID, pidfromfile, &nproc);
+	else
+		plist = kvm_getprocs(kd, KERN_PROC_PROC, 0, &nproc);
 	if (plist == NULL) {
 		errx(STATUS_ERROR, "Cannot get process list (%s)",
 		    kvm_geterr(kd));



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201311100522.rAA5MTsf009249>