What does Unix `kill -0 PID` mean?

March 24, 2015 - Unix

Ran across this problem earlier today in my work, couldn’t understand what the use and purpose of the following statement was:

kill -0 $PID

I consulted the kill man page and online references but was left without a clear answer. Finally, I found a reference 1“Linux / UNIX: Kill Command Examples.” Linux Unix Tutorial for Beginners and Advanced Users NixCraft RSS. NixCraft, 2 Jan. 2009. Web. 24 Mar. 2015. <http://www.cyberciti.biz/faq/unix-kill-command-examples/>. that explained it briefly, and after conducting some experiments, confirmed my understanding.

Answer: The kill -0 $PID  technique checks to see if the particular PID is accessible. Thus, it can be used to verify a PID exists, and to kill it only if it exists.

References   [ + ]

1. “Linux / UNIX: Kill Command Examples.” Linux Unix Tutorial for Beginners and Advanced Users NixCraft RSS. NixCraft, 2 Jan. 2009. Web. 24 Mar. 2015. <http://www.cyberciti.biz/faq/unix-kill-command-examples/>.

Leave a Reply

Your email address will not be published. Required fields are marked *