Run child process with stdout and result on Win32?

D

Dave Sellars

Is there really no way to run a sub-process, gather its stdout/stderr,
and collect the return-code, on Win32???
But that's what the docs say...
> These methods do not make it possible to retrieve the return code
> from the child processes. The only way to control the input and
> output streams and also retrieve the return codes is to use the
> Popen3 and Popen4 classes from the popen2 module; these are only
> available on Unix.

Surely not!?!?

Dave.
 
D

Duncan Booth

Is there really no way to run a sub-process, gather its stdout/stderr,
and collect the return-code, on Win32???
But that's what the docs say...


Surely not!?!?

Dave.

Bizarrely, the return code is returned as the result of the *last* call to
the close method on any of the file handles returned. i.e. You must close
all of stdin, stdout and stderr handles returned (usually after
reading/writing), and the last one you close will return a numeric exit
code if the command returned a non-zero exit code. If the command returned
a 0 exit code then the final close returns None.

So far as I can see, the documentation omits to mention this little fact (I
read the source).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,816
Latest member
nipsseyhussle

Latest Threads

Top