[buug] checking a pid

Ian Zimmerman itz at speakeasy.org
Thu Feb 27 10:54:05 PST 2003


itz> How does one check in general if a number is a pid of a living
itz> process, under BSD?  The old saw kill(pid, 0) only works for my
itz> own processes - it will fail for other users' processes whether
itz> or not pid is alive.

Sean> But if kill returns non-zero, and the process exists and is not
Sean> owned by you, errno will be set to EPERM, whereas if the process
Sean> does not exist errno will be set to ESRCH.  So it is still
Sean> possible to use this method to check for the existence of a
Sean> process, regardless of its owner.

Ahhh, true!  The answer I was looking for.  Thanks.

-- 
Ian Zimmerman, Oakland, California, U.S.A. 
if (sizeof(signed) > sizeof(unsigned) + 4) { delete this; }
GPG: 433BA087  9C0F 194F 203A 63F7 B1B8  6E5A 8CA3 27DB 433B A087



More information about the buug mailing list