From owner-svn-src-head@freebsd.org Tue Aug 8 00:31:11 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A1ECDDD2CD9; Tue, 8 Aug 2017 00:31:11 +0000 (UTC) (envelope-from lstewart@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6FCB365092; Tue, 8 Aug 2017 00:31:11 +0000 (UTC) (envelope-from lstewart@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v780VAK0081188; Tue, 8 Aug 2017 00:31:10 GMT (envelope-from lstewart@FreeBSD.org) Received: (from lstewart@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v780VAij081187; Tue, 8 Aug 2017 00:31:10 GMT (envelope-from lstewart@FreeBSD.org) Message-Id: <201708080031.v780VAij081187@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: lstewart set sender to lstewart@FreeBSD.org using -f From: Lawrence Stewart Date: Tue, 8 Aug 2017 00:31:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322210 - head/bin/pkill X-SVN-Group: head X-SVN-Commit-Author: lstewart X-SVN-Commit-Paths: head/bin/pkill X-SVN-Commit-Revision: 322210 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Aug 2017 00:31:11 -0000 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 #include +#include #include #include #include @@ -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); }