develooper Front page | perl.perl5.porters | Postings from April 2007

Re: [PATCH] Fix kill(0, $pid) on Windows

Thread Previous | Thread Next
Garrett Cooper
April 17, 2007 20:46
Re: [PATCH] Fix kill(0, $pid) on Windows
Message ID:
Jan Dubois wrote:
> On Tue, 17 Apr 2007, wrote:
>> Try this:
>> perl -e 'kill 15, undef; print "Hello, cruel world!";'
>> And yes, I was the person that originally sent the bug report. If
>> someone could provide me with the POSIX spec that says that an
>> undefined value equals 0, and a 0 value with kill works out to kill
>> the calling process, I'd appreciate it.
> From `perldoc -f kill`:
>     kill SIGNAL, LIST
>             Sends a signal to a list of processes. Returns the number of
>             processes successfully signaled (which is not necessarily the
>             same as the number actually killed).
> Processes are identified by PID, which is a number. `perldoc perlsyn`
> says this:
>                                          When used as a number, "undef" is
>     treated as 0; when used as a string, it is treated as the empty string,
> This means that kill(15, undef) should be treated the same as kill(15, 0)
> due to Perl data transformation rules.
> POSIX ( 
> says this about using a PID of 0:
>     If pid is 0, sig shall be sent to all processes (excluding an
>     unspecified set of system processes) whose process group ID is equal
>     to the process group ID of the sender, and for which the process has
>     permission to send a signal.
> Therefore `kill(15, undef)` should send signal 15 to all processes in
> the current process group, including the process issuing the kill()
> call itself.
> Cheers,
> -Jan

	Could someone maybe write that as a gotcha in the perldoc? It seems to 
be a bit more encompassing, knowledgewise, to realize that, and it also 
seems like it could bite some devs in the proverbial rear if they didn't 
know that.

	Thanks though for the lesson :).

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About