How do I check if a pid is running?

Erlend J. Leiknes nookieNO_SP_AM at online.no
Tue May 14 02:38:37 EDT 2002


Is there a cross-platform method for this? (im thinking of windows and unix
(screw mac))


"Noah" <noah at noah.org> wrote in message
news:mailman.1020977838.496.python-list at python.org...
>
> 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