Proccess termination

Diez B. Roggisch deetsNOSPAM at
Fri Jan 28 14:15:36 CET 2005

alexrait1 wrote:

> I use popen.popen2 or popen.popen3 to start a new process and read from
> it's stdout/ write to it's stdin.
> But I need a way to know when a process terminates. If it closes it's
> stdin/stdout, it doesn't mean it has really terminated...

You can use the Popen-objects pid to see if a process still runs. 

> And if possible, I would like to see an exception thrown when that
> happens..

Not possible - that exception would be asynchronous to your program flow.
The only thing I can think of that would make this possible is to have a
second thread waiting for process termination - and sending the own process
a signal. If I'm not mistaken, that will be propagated to the main thread.

All this is meant to be running on unix - not sure how thinks work out on


Diez B. Roggisch

More information about the Python-list mailing list