Index: pkill.c =================================================================== RCS file: /cvsroot/src/usr.bin/pkill/pkill.c,v retrieving revision 1.30 diff -u -r1.30 pkill.c --- pkill.c 9 Jan 2015 12:45:32 -0000 1.30 +++ pkill.c 13 Oct 2015 17:04:16 -0000 @@ -104,9 +104,9 @@ static struct listhead sidlist = SLIST_HEAD_INITIALIZER(list); static void usage(void) __dead; -static int killact(const struct kinfo_proc2 *); -static int reniceact(const struct kinfo_proc2 *); -static int grepact(const struct kinfo_proc2 *); +static int killact(const struct kinfo_proc2 *, int); +static int reniceact(const struct kinfo_proc2 *, int); +static int grepact(const struct kinfo_proc2 *, int); static void makelist(struct listhead *, enum listtype, char *); int @@ -114,7 +114,7 @@ { char buf[_POSIX2_LINE_MAX], **pargv, *q; int i, j, ch, bestidx, rv, criteria; - int (*action)(const struct kinfo_proc2 *); + int (*action)(const struct kinfo_proc2 *, int); const struct kinfo_proc2 *kp; struct list *li; const char *p; @@ -413,7 +413,7 @@ /* * Take the appropriate action for each matched process, if any. */ - for (i = 0, rv = 0, kp = plist; i < nproc; i++, kp++) { + for (i = 0, j = 0, rv = 0, kp = plist; i < nproc; i++, kp++) { if (kp->p_pid == mypid) continue; if (selected[i]) { @@ -425,8 +425,10 @@ if ((kp->p_flag & P_SYSTEM) != 0) continue; - rv |= (*action)(kp); + rv |= (*action)(kp, j++); } + if (pgrep || (!prenice && longfmt)) + putchar('\n'); return rv ? STATUS_MATCH : STATUS_NOMATCH; } @@ -456,10 +458,10 @@ } static int -killact(const struct kinfo_proc2 *kp) +killact(const struct kinfo_proc2 *kp, int printdelim) { if (longfmt) - grepact(kp); + grepact(kp, printdelim); if (kill(kp->p_pid, signum) == -1) { /* @@ -482,12 +484,14 @@ } static int -reniceact(const struct kinfo_proc2 *kp) +reniceact(const struct kinfo_proc2 *kp, int printdelim) { int oldprio; - if (longfmt) - grepact(kp); + if (longfmt) { + grepact(kp, printdelim); + putchar('\n'); + } errno = 0; if ((oldprio = getpriority(PRIO_PROCESS, kp->p_pid)) == -1 && @@ -508,10 +512,13 @@ } static int -grepact(const struct kinfo_proc2 *kp) +grepact(const struct kinfo_proc2 *kp, int printdelim) { char **argv; + if (printdelim) + (void)printf("%s", delim); + if (longfmt && matchargs) { /* @@ -534,8 +541,6 @@ else (void)printf("%d", (int)kp->p_pid); - (void)printf("%s", delim); - return 1; }