[comp.unix.xenix] kill

pim@ctisbv.UUCP (Pim Zandbergen) (03/22/89)

Hi netlanders,

In our business applications, kill(pid, 0) is used to check
whether a process that has exclusively claimed a resource is still alive.

kill(pid, 0) is supposed to do error checking only, but not to
actually send a signal. I strongly suspect, however, 
that in some cases, probarly depending on the phase of the moon,
valid processes are being killed by others who check fo their existance.

This is how the code looks like:

	/* look up the pid from a lock-file */
	...
	/* check for its validity */
	if ((kill(pid, 0) < 0) && (errno == ESRCH))
	{
		/* process does not exist; claim resource */
		...
	}
	else
	{
		/* tell the user the bad news */
		...
	}

Has anybody else experienced this behaviour? This is about
the same scheme uucp uses to check the validity of the LCK..
files. Has anybody seen the same problem there?

Thanks in advance for any hints!
-- 
--------------------+----------------------+-----------------------------------
Pim Zandbergen      | phone: +31 70 542302 | CTI Software BV
pim@ctisbv.UUCP     | fax  : +31 70 512837 | Laan Copes van Cattenburch 70
...!uunet!mcvax!hp4nl!ctisbv!pim           | 2585 GD The Hague, The Netherlands