Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!sdd.hp.com!decwrl!bacchus.pa.dec.com!decvax.dec.com!zinn!lemuria!darryl From: darryl@lemuria.MV.COM (Darryl Wagoner) Newsgroups: comp.unix.questions Subject: Re: How to tell if a process exists Message-ID: <1325@lemuria.MV.COM> Date: 7 Aug 90 01:29:28 GMT References: <26B867F8.38BB@wilbur.coyote.trw.com> Reply-To: darryl@lemuria.UUCP (Darryl Wagoner) Organization: Shecora Associates, Inc. Nashua, NH Lines: 20 In article <26B867F8.38BB@wilbur.coyote.trw.com> rudoff@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@lemuria.MV.COM or uunet!virgin!lemuria!darryl 12 Oak Hill Road Brookline, NH 03033 Office: 603.672.0736 Home: 603.673.0578