Summary - How to tell if a process is active

Mike Hoffman mhoffman at infocenter.UUCP
Tue Jun 20 23:18:39 AEST 1989


In an earlier message, I wrote:
>I have an application in which I need to check to see if a process
>is currently active.

Thanks to all who answered my request for a better approach. The
correct way to tell if a process is active is by using kill(2),
and sending a signal of 0. This will perform error checking, but
does not actually send a signal to the process.

Kill(2) returns 0 if the process exists and is yours, or -1 
otherwise. If -1 is returned, errno is set to any of several
values, the most relevant of which are EPERM (the process exists
but is not yours) and ESRCH (the process does not exist).

In one response, Casper H.S. Dik (casper at fwi.uva.nl) points out
that "As often is the case with Unix manuals, if you know where
to look you get perfect answers." For me, kill wasn't a very
obvious place to look for process information!

Thanks to the following people for responding to my request (and
for providing consistent answers - this turned out to be much
simpler than finding the meaning of "grep" :-)

    casper at fwi.uva.nl
    uunet!prcrs!paul
    uunet!atexnet!jackal 
    ram at cuxlm.att.com   
    uunet!mcnc!unc!poirier
    uunet!noifcrf.gov!kml
    jeff at quark.wv.tek.com
    peter at ficc.uu.net
    uunet!arizona!sham

---
Michael J. Hoffman                   "My opinions are my own and are
Manufacturing Engineering             not to be employed with those
Encore Computer Corporation           of my confuser."
                            
UUCP: {uunet,codas!novavax,sun,pur-ee}!gould!mhoffman



More information about the Comp.unix.questions mailing list