KILL!

Bill Campbell linux-sxs
Thu Feb 1 21:17:26 PST 2007


On Thu, Feb 01, 2007, Matthew Carpenter wrote:
>Any C programmers out there have a good understanding of the ins and outs of 
>GLIB's "kill" function?
>
>Specifically, it indicates that if the SIGNAL sent is 0, no signal is actually 
>sent but error checking is processed.  Quoted from the man page:
>
>	int kill(pid_t pid, int sig);
><snip>
> "If sig is 0, then no signal is sent, but error checking is still performed."
>
>What the freak does that mean!?  Why would you call kill without actually 
>wanting to send a signal!?  Why did the chicken cross the road!?  Was it just 
>to see if he could!  little prick.  er...  chick.

The ``kill -0'' is generally used to test the existence of a
process, and is often used in conjunction with a *.pid file to
see if daemons are functioning.  In shell speak this might be:

pidfile="..." point to a daemon's daemonname.pid file

active='no'
test -e $pidfile && kill -0 `cat $pidfile` && {
	active='yes'
}

Bill
--
INTERNET:   bill at Celestial.COM  Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/  PO Box 820; 6641 E. Mercer Way
FAX:            (206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676

``It will be of little avail to the people that the laws are made by men of
their own choice if the laws be so voluminous that they cannot be read, or
so incoherent that they cannot be understood.''
    -James Madison, Federalist Paper #62



More information about the Linux-users mailing list