Subject: bin/21933: pkill doesn't behave as documented
To: None <>
From: Christian Biere <>
List: netbsd-bugs
Date: 06/19/2003 23:22:12
>Number:         21933
>Category:       bin
>Synopsis:       pkill doesn't behave as documented
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 19 21:23:00 UTC 2003
>Originator:     Christian Biere
>Release:        NetBSD 1.6R

pkill exits when kill(2) fails. This isn't mentioned in the
documentation and it doesn't look reasonable to me. E.g., if a process
disappeared just before kill(2) pkill will bail out and leave the next
processes in the list alone. Furthermore, the manual page mentions that
pkill was modelled after the counterparts on Solaris. On Solaris pkill
doesn't care if kill failed - at least, not about EPERM - it warns only
and keeps on killing each matching process.


Imagine there's more than user on the machine:

pkill xterm
pkill: signalling pid 22549: Operation not permitted

Thus, you would have to use pkill -U `whoami` xterm or hope that your
own xterms come first. IMO the aim of pkill is to provide a quick and
comfortable variant of kill. Therefore, I consider the current behaviour
to be somewhat annoying.


The following patch replaces err() by warn() in killact() making pkill
behave as mentioned above.

Content-Type: text/plain;
Content-Disposition: attachment;
Content-Transfer-Encoding: 7bit

Index: pkill.c
RCS file: /cvsroot/src/usr.bin/pkill/pkill.c,v
retrieving revision 1.5
diff -u -r1.5 pkill.c
--- pkill.c	2002/10/27 11:49:34	1.5
+++ pkill.c	2003/06/19 21:02:00
@@ -422,7 +422,7 @@
 	if (kill(kp->p_pid, signum) == -1)
-		err(STATUS_ERROR, "signalling pid %d", (int)kp->p_pid);
+		warn("signalling pid %d", (int)kp->p_pid);

 This is a multi-part message in MIME format.
 Content-Type: text/plain; charset=US-ASCII
 Content-Transfer-Encoding: 7bit