Gabriel Genellina added the comment: (I think the title you meant was "popen spawned process may not write to stderr under windows")
The child is dying with IOError: [Errno 22] Invalid argument at the sys.stderr.flush() call. Neither the docs for os.popen nor the Linux man page for popen(3) say that stderr is redirected, so one would expect the handle to be inherited; the IOError looks like a bug. Try using os.popen4 or popen2.popen4 or -the recommended choice- the subprocess module. Using the latter, this is the modified parent.py: """ import subprocess cmd = 'python child.py' p = subprocess.Popen(cmd, stdout=subprocess.PIPE) for line in p.stdout: print ">>>", line, print p.wait() """ and this is the output, as expected: """ 2:stderr >>> 1:stdout >>> 3:stdout 0 """ Note the 2:stderr line lacking the >>>, because it was printed directly by the child process onto the stderr handle inherited from its parent. ---------- nosy: +gagenellina __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue1366> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com