Best way to determine if a certain PID is still running
David Hirschfield
davidh at ilm.com
Thu Feb 2 20:10:24 EST 2006
I'm launching a process via an os.spawnvp(os.P_NOWAIT,...) call.
So now I have the pid of the process, and I want a way to see if that
process is complete.
I don't want to block on os.waitpid(), I just want a quick way to see if
the process I started is finished. I could popen("ps -p %d" % pid) and
see whether it's there anymore...but since pids get reused, there's the
chance (however remote) that I'd get a false positive, plus I don't
really like the idea of calling something non-pure-python to find out.
So, should I run a monitor thread which just calls os.waitpid() and when
the thread indicates via an event that the process completed, I'm golden?
All suggestions welcome, looking for simple and clean over wickedly-clever,
-David
--
Presenting:
mediocre nebula.
More information about the Python-list
mailing list