os.popen4 and exit codes
Don Garrett
garrett at bgb.cc
Mon Mar 18 17:32:43 EST 2002
My understanding for the popen2-4 functions was that they returned the exit
code as the result of the last related call to close(). This seems to be
working for me under Windows, but not Linux. This is the inverse of what I
would expect.
I'm running Python 2.2 built from the src RPM on a RedHat 7.2 machine, but
found the same problem using the Python2 RPMs distributed by RedHat.
As an example:
>>> (stdin, stdout, stderr) = os.popen3("false")
>>> stdin.close()
>>> stdout.close()
>>> stderr.close()
I would expect the close of stderr to return 256, but that doesn't seem to
happen.
The close DOES return the exit code when I use os.popen(), but I need to be
able to capture stderr.
Is this a known bug, am I doing something wrong, and/or is there a decent
workaround? I could do something funky like extend the command line to print
the error code on the last line of output, but I'd prefer to do this right if
I can.
Thanks for any help!
--
Don Garrett http://www.bgb.cc/garrett/
BGB Consulting garrett at bgb.cc
More information about the Python-list
mailing list