[talk] kill -0

Pete Wright pete at nomadlogic.org
Fri May 10 15:06:27 EDT 2019



On 2019-05-10 11:59, Pete Wright wrote:
>
>
> On 2019-05-10 11:00, Raul Cuza wrote:
>> Hola People Who Use Shells,
>>
>> I just had someone submit a shell script using `kill -0 ${PID}` to
>> test if a process is running. It exits non-zero if ${PID} isn't a
>> running process and zero otherwise. But...
>>
>> http://nixdoc.net/man-pages/FreeBSD/kill.1.html says nothing about it.
>>
>> The ubuntu man page mentions it poorly with "Particularly useful
>> signals include HUP, INT, KILL, STOP, CONT, and 0." Looking at `kill
>> --list` there is no signal 0.
>>
>> And stackoverflow says
>> https://stackoverflow.com/questions/11012527/what-does-kill-0-pid-in-a-shell-script-do 
>>
>> matching what the person who submitted the PR says.
>>
>> Am I wrong to think this should be accomplished in a way with better
>> documentation? I feel like I am nit picking.
>
> this seems like a bash'ism - from the bash manpage:
>
> SIGNALS
>        When bash is interactive, in the absence of any traps, it ignores
>        SIGTERM (so that kill 0 does not kill an interactive shell), 
> and SIGINT
>        is caught and handled (so that the wait builtin is 
> interruptible).  In
>        all cases, bash ignores SIGQUIT.  If job control is in effect, 
> bash
>        ignores SIGTTIN, SIGTTOU, and SIGTSTP.
>
>

heh wish i saw Jan's post before i wrote this as his reply seems to 
answer the real question...

-p

-- 
Pete Wright
pete at nomadlogic.org
@nomadlogicLA



More information about the talk mailing list