Author ggenellina
Recipients ggenellina, pmezard
Date 2007-11-07.15:48:50
SpamBayes Score 0.015052
Marked as misclassified No
Message-id <>
(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 

import subprocess
cmd = 'python'
p = subprocess.Popen(cmd, 
for line in p.stdout:
  print ">>>", line,
print p.wait()

and this is the output, as 

>>> 1:stdout
>>> 3:stdout

Note the 2:stderr line lacking the 
>>>, because it was printed 
directly by the child process onto 
the stderr handle inherited from 
its parent.
Date User Action Args
2007-11-07 15:48:51ggenellinasetspambayes_score: 0.015052 -> 0.015052
recipients: + ggenellina, pmezard
2007-11-07 15:48:51ggenellinasetspambayes_score: 0.015052 -> 0.015052
messageid: <>
2007-11-07 15:48:51ggenellinalinkissue1366 messages
2007-11-07 15:48:50ggenellinacreate