Best way to determine if a certain PID is still running

MrJean1 MrJean1 at gmail.com
Fri Feb 3 20:04:05 EST 2006


Take look at the poll() methods in the subprocess.py source file of
your Python install.

It shows how to use the os.wait_pid(pid, os.WNOHANG) to check whether a
process is still running or has terminated (and how, from the returned
status value).

Btw, on *nix you must call os.wait_pid(pid, ...) to avoid creating
zombie processes.

Using the subprocess module hides and handles all those details for
you, both on *nix and Windows.

/Jean Brouwers




More information about the Python-list mailing list