From: John P. Linderman Date: Sun, 10 Aug 2003 15:44:33 +0000 (-0400) Subject: Re: killing for vital signs [PATCH] X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1e9c1022d083eab04a1d88cf3f92a6f2fc2b0791;p=p5sagit%2Fp5-mst-13.2.git Re: killing for vital signs [PATCH] From: "John P. Linderman" Message-Id: <200308101944.PAA96547@raptor.research.att.com> p4raw-id: //depot/perl@20607 --- diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index f47b6a5..f10927e 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -2378,7 +2378,7 @@ same as the number actually killed). kill 9, @goners; If SIGNAL is zero, no signal is sent to the process. This is a -useful way to check that the process is alive and hasn't changed +useful way to check that a child process is alive and hasn't changed its UID. See L for notes on the portability of this construct. @@ -2386,7 +2386,9 @@ Unlike in the shell, if SIGNAL is negative, it kills process groups instead of processes. (On System V, a negative I number will also kill process groups, but that's not portable.) That means you usually want to use positive not negative signals. You may also -use a signal name in quotes. See L for details. +use a signal name in quotes. + +See L for more details. =item last LABEL diff --git a/pod/perlipc.pod b/pod/perlipc.pod index 637030c..8412bfd 100644 --- a/pod/perlipc.pod +++ b/pod/perlipc.pod @@ -95,13 +95,22 @@ it doesn't kill itself): } Another interesting signal to send is signal number zero. This doesn't -actually affect another process, but instead checks whether it's alive +actually affect a child process, but instead checks whether it's alive or has changed its UID. unless (kill 0 => $kid_pid) { warn "something wicked happened to $kid_pid"; } +When directed at a process whose UID is not identical to that +of the sending process, signal number zero may fail because +you lack permission to send the signal, even though the process is alive. +You may be able to determine the cause of failure using C<$!>. + + unless (kill 0 => $pid or $! == $!{EPERM}) { + warn "$pid looks dead"; + } + You might also want to employ anonymous functions for simple signal handlers: