Date: Sat, 3 Mar 2018 10:43:41 +0000 (UTC) From: Eitan Adler <eadler@FreeBSD.org> 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 Message-ID: <201803031043.w23Ahf1F035732@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <sys/user.h> #include <assert.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <limits.h> @@ -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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201803031043.w23Ahf1F035732>