How to tell if a process exists
Darryl Wagoner
darryl at lemuria.MV.COM
Tue Aug 7 11:29:28 AEST 1990
In article <26B867F8.38BB at wilbur.coyote.trw.com> rudoff at mdi.com writes:
>
>In a C program, how do you tell if a certain process exists? A
>kill(0,pid) works only if you own the process (or you're root). It
>seems like such a simple thing to request that it should be part of
>the standard C libraries for unix, but I can't seem to find the right
>thing to use.
No, you can use kill(0,pid) even if you don't own the process. If the
process is running and own by someone else, then you get a EPERM error,
if the process doesn't exist then you get ESRCH error, and if the
process is killable by you then kill returns a zero. The error codes
may be different on Ultrix but you get the idea.
--
Darryl Wagoner darryl at lemuria.MV.COM or uunet!virgin!lemuria!darryl
12 Oak Hill Road
Brookline, NH 03033
Office: 603.672.0736 Home: 603.673.0578
More information about the Comp.unix.questions
mailing list