If, between the internal grep'ing and the printout, a process has disappeared, we currently get an empty line and pgrep will return nonzero.
This makes it, IMHO, behave somewhat better. OK? Better wording? Could there be other reasons kvm_getargv fails? /Alexander Index: pkill.c =================================================================== RCS file: /data/openbsd/cvs/src/usr.bin/pkill/pkill.c,v retrieving revision 1.30 diff -u -p -r1.30 pkill.c --- pkill.c 21 Aug 2012 10:32:38 -0000 1.30 +++ pkill.c 6 Dec 2012 09:47:39 -0000 @@ -470,15 +470,15 @@ grepact(struct kinfo_proc *kp, int print if (printdelim) fputs(delim, stdout); if (longfmt && matchargs) { - if ((argv = kvm_getargv(kd, kp, 0)) == NULL) - return (-1); - - printf("%d ", (int)kp->p_pid); - for (; *argv != NULL; argv++) { - printf("%s", *argv); - if (argv[1] != NULL) - putchar(' '); - } + if ((argv = kvm_getargv(kd, kp, 0)) != NULL) { + printf("%d ", (int)kp->p_pid); + for (; *argv != NULL; argv++) { + printf("%s", *argv); + if (argv[1] != NULL) + putchar(' '); + } + } else + printf("%d (terminated)", (int)kp->p_pid); } else if (longfmt) printf("%d %s", (int)kp->p_pid, kp->p_comm); else