Path: utzoo!utgpu!water!watmath!clyde!rutgers!mit-eddie!uw-beaver!tektronix!orca!tekecs!frip!andrew
From: andrew@frip.gwd.tek.com (Andrew Klossner)
Newsgroups: comp.unix.wizards
Subject: Re: Is process  alive?
Message-ID: <9500@tekecs.TEK.COM>
Date: 10 Dec 87 22:02:15 GMT
References: <1454@rtech.UUCP> <1921@munnari.oz> <429@minya.UUCP>
Sender: nobody@tekecs.TEK.COM
Organization: Tektronix, Wilsonville, Oregon
Lines: 16


	"On this SysV, this can be done (with some difficulty) by doing
	a kill(0,n), which doesn't actually do anything to the process
	(as far as I can tell), but it does return different values in
	errno for no-such-process and for wrong-uid ...  So far, I
	haven't tried to solve the problem on BSD, but the above remark
	implies that my SysV code won't work."

Your code will work.  BSD kill(2) guarantees that validity checking
happens in this order: first that the signal number is valid (and 0
is); next that the target process exists; next that you're allowed to
send the signal; next (other irrelevancies).  Thus, kill(pid,0) will
always return errno==ESRCH if pid doesn't exist.

  -=- Andrew Klossner   (decvax!tektronix!tekecs!andrew)       [UUCP]
                        (andrew%tekecs.tek.com@relay.cs.net)   [ARPA]