How to tell if a process exists

Randal Schwartz merlyn at iwarp.intel.com
Fri Aug 3 14:01:21 AEST 1990


In article <26B867F8.38BB at wilbur.coyote.trw.com>, doug at ridley (Doug Rudoff) 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.

On a normal UNIX (although you mentioned Ultrix later, so all bets may
be off), you will get success or EPERM if the process exists, and
ESRCH if the process does not exist.  With this sort of algorithm, it
doesn't matter who you are.  Just remember to check errno!

Just another UNIX hacker,
-- 
/=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\
| on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III      |
| merlyn at iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn |
\=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/



More information about the Comp.unix.questions mailing list