kill -0 <pid> --- side effect or supported

Mateusz Guzik mjguzik at gmail.com
Fri Mar 3 22:22:06 UTC 2017


On Fri, Mar 03, 2017 at 11:12:26PM +0100, Dirk-Willem van Gulik wrote:
> I regularly use  'kill -0 <pid>' on FreeBSD as  a way to test if a certain process is still running (but without actually sending the signal). And I think it has worked reliably since the mid 80's.
> 
> Is it actually a properly supported use - as I recently happened to notice that it does not seem to be all that documented in kill(
> 

The signal 0 is mostly used to check if you can deliver signals in the
first place.

The problem with 'is alive?' checks with this mechanism is that zombies
eat up any signal sent, including 0.

For a shell script this may be good enough, but chances are you want to
invest into something which actually tracks children as opposed to just
dropping pidfiles.

-- 
Mateusz Guzik <mjguzik gmail.com>


More information about the freebsd-hackers mailing list