popen: how to make sure child process is terminated and get return code?

Anders Dalvander google at dalvander.com
Thu Oct 30 04:40:48 EST 2003


Tung Wai Yip <tungwaiyip at yahoo.com> wrote in message news:<dmsipvoeqj35tq876d4bk372vdjgsovfht at 4ax.com>...
> Secondly, the is some documention on popen() about how to get the
> return code. But there is almost none for popen2-4(). What I discover
> is it has to close all streams and the last one will give some the
> return code.

Disclaimer: I'm new to Python

I'm in the same situation as you are, I'm trying to popen4 a program
and getting the stdout and stderr from it.

The documentation states that popen[2-4] does not support a way of
getting the return code. But I've found it to be the return value for
the last close-call you make on what popen4 returned. I'm also on
Win2K. I don't know if it is the same for other platforms, but I think
it should be some sort of standard way of doing this rather common and
simple thing.




More information about the Python-list mailing list