What does `kill -0` do?

I am having trouble understanding shell script below. Specifically, what is Kill -0 (zero)

while kill -0 ${docker_pid} 2>/dev/null
do #do something here
done

All the documentation for kill signals I have found starts documenting from 1...31

#ifndef _POSIX_SOURCE
#include <machine/trap.h> /* codes for SIGILL, SIGFPE */
#endif /* _POSIX_SOURCE */
#define SIGHUP 1 /* hangup */
#define SIGINT 2 /* interrupt */
#define SIGQUIT 3 /* quit */
#define SIGILL 4 /* illegal instruction (not reset when caught) */
#ifndef _POSIX_SOURCE
#define SIGTRAP 5 /* trace trap (not reset when caught) */
#endif
... signal.h continues ....

1 Answer

kill -0 <pid> just gives a return value 0 if the process exists, and 1 if it doesn't.

5

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like