Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 Aug 2017 00:31:10 +0000 (UTC)
From:      Lawrence Stewart <lstewart@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r322210 - head/bin/pkill
Message-ID:  <201708080031.v780VAij081187@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: lstewart
Date: Tue Aug  8 00:31:10 2017
New Revision: 322210
URL: https://svnweb.freebsd.org/changeset/base/322210

Log:
  pgrep naively appends the delimiter to all PIDs including the last
  e.g. "pgrep -d, getty" outputs "1399,1386,1309,1308,1307,1306,1305,1302,"
  Ensure the list is correctly delimited by suppressing the emission of the
  delimiter after the final PID.
  
  Reviewed by:	imp, kib
  MFC after:	1 week
  Sponsored by:	Netflix, Inc.
  Differential Revision:	https://reviews.freebsd.org/D8537

Modified:
  head/bin/pkill/pkill.c

Modified: head/bin/pkill/pkill.c
==============================================================================
--- head/bin/pkill/pkill.c	Mon Aug  7 23:33:05 2017	(r322209)
+++ head/bin/pkill/pkill.c	Tue Aug  8 00:31:10 2017	(r322210)
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/user.h>
 
 #include <assert.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <limits.h>
@@ -656,10 +657,12 @@ killact(const struct kinfo_proc *kp)
 static int
 grepact(const struct kinfo_proc *kp)
 {
+	static bool first = true;
 
-	show_process(kp);
-	if (!quiet)
+	if (!quiet && !first)
 		printf("%s", delim);
+	show_process(kp);
+	first = false;
 	return (1);
 }
 



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