Finding if a process is active

Doug Gwyn gwyn at smoke.BRL.MIL
Wed Jun 13 14:19:26 AEST 1990


In article <1629 at s3.ireq.hydro.qc.ca> godin at ireq.hydro.qc.ca (Andre Godin 8926) writes:
>   I have a process (written in C) running under SunOS 4.0.3 that
>have to find out if a process exist, knowing only his name.

Processes don't have names, only numbers (PIDs).  The image that was
exec()ed came from a file that had a name, but the process could
easily alter the only record of the name assigned to its argv[0],
which is normally set to the "simple part" of the file name by the
shell used to exec() the process.  (But that is just a convention,
not necessarily followed by all exec()ers.)

>   Is there a system call (or something else) that can tell me if
>a certain process is active?

kill(pid,0) will tell you whether or not process #pid is active,
assuming you have appropriate permissions.



More information about the Comp.unix.questions mailing list