How do I check if a pid is running?

Noah noah at noah.org
Thu May 9 16:55:39 EDT 2002


If I have the pid to a process under UNIX then how do I get the status of that pid?
Specifically, I would like to see if child is running or not.
If the pid cannot even be found then I will assume that 
process is not running.

Note, that I think waitpid() may do what I want, but I'm not
quite sure of the semantics. I do not want to wait for completion 
of a child process, so I probably need WNOHANG option, but that
returns 0 if the status is not immediately available, so presumably
the process could still be running. Therefore a 0 value is ambiguous.

What do I need to do just to check if the pid even exists or not?

Yours,
Noah





More information about the Python-list mailing list