Subject: bin/21933: pkill doesn't behave as documented
To: None <gnats-bugs@gnats.netbsd.org>
From: Christian Biere <christianbiere@gmx.de>
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
>Closed-Date:
>Last-Modified:
>Originator:     Christian Biere
>Release:        NetBSD 1.6R
>Organization:
>Environment:

>Description:
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.

>How-To-Repeat:

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.

>Fix:

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

--Multipart_Thu__19_Jun_2003_23:22:12_+0200_08225a00
Content-Type: text/plain;
 name="pkill.c.udif"
Content-Disposition: attachment;
 filename="pkill.c.udif"
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);
 }
 
 void

--Multipart_Thu__19_Jun_2003_23:22:12_+0200_08225a00--
>Release-Note:
>Audit-Trail:
>Unformatted:
 This is a multi-part message in MIME format.
 
 --Multipart_Thu__19_Jun_2003_23:22:12_+0200_08225a00
 Content-Type: text/plain; charset=US-ASCII
 Content-Transfer-Encoding: 7bit