From owner-svn-src-stable-11@freebsd.org Sat Mar 3 10:43:42 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 62B4BF2F980; Sat, 3 Mar 2018 10:43:42 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1382B7A5E2; Sat, 3 Mar 2018 10:43:42 +0000 (UTC) (envelope-from eadler@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0E737253E4; Sat, 3 Mar 2018 10:43:42 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w23AhfaR035733; Sat, 3 Mar 2018 10:43:41 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w23Ahf1F035732; Sat, 3 Mar 2018 10:43:41 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201803031043.w23Ahf1F035732@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Sat, 3 Mar 2018 10:43:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r330324 - stable/11/bin/pkill X-SVN-Group: stable-11 X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: stable/11/bin/pkill X-SVN-Commit-Revision: 330324 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Mar 2018 10:43:42 -0000 Author: eadler Date: Sat Mar 3 10:43:41 2018 New Revision: 330324 URL: https://svnweb.freebsd.org/changeset/base/330324 Log: MFC r322210,r322613,r322831: 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. The r322210 change to pgrep's PID delimiting behaviour causes pgrep's default output to not include a trailing new line, which is a potential POLA violation for existing consumers. Change pgrep to always emit a trailing new line on completion of its output, regardless of the delimeter in use (which technically is also a potential POLA violation for existing consumers that rely on the pre-r322210 buggy behaviour, but a line has to be drawn somewhere). Only emit the trailing new line added in r322613 when not operating in quiet mode. PR: 221534 (r322613) Modified: stable/11/bin/pkill/pkill.c Directory Properties: stable/11/ (props changed) Modified: stable/11/bin/pkill/pkill.c ============================================================================== --- stable/11/bin/pkill/pkill.c Sat Mar 3 10:37:53 2018 (r330323) +++ stable/11/bin/pkill/pkill.c Sat Mar 3 10:43:41 2018 (r330324) @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -567,6 +568,8 @@ main(int argc, char **argv) continue; rv |= (*action)(kp); } + if (rv && pgrep && !quiet) + putchar('\n'); if (!did_action && !pgrep && longfmt) fprintf(stderr, "No matching processes belonging to you were found\n"); @@ -656,10 +659,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); }