Hi,
I think I have possibly found a bug in the subprocess module. The (potential)
bug appears when executing a subprocess from a daemon (after double-forking).
This is on RHEL 6.2 with python version 2.6.6.
The problem can be demonstrated with the two attached files, both files should
be made executable and then run './example'. There is output both on stdout
and in the file: '/tmp/example.log'.
The 'service' program writes on both stdout and stderr, sleeps 10 seconds and
exits.
The 'exemple' program executes the subprocess, 'service', (to demonstrate that
the subprocess module works), then double-forks, closes file-desciptors, points
sys.stdout and sys.stderr to a logfile and executes the 'service' subprocess
again. The second execution fails when the subprocess references sys.stderr.
If the ' print >>sys.stderr, ...' line is commented out of the 'service' file,
the second execution succeeds. The first call to subprocess.Popen produces
output on stdout, the second call outputs to '/tmp/example.log'. On the other
hand, if the lines in 'service' that are commented out (write on
'/tmp/service.out') are enabled, the stderr output appears in that file.
If I use 'os.popen3' instead of ' subprocess.Popen', the problem disappears.
I would love to hear your opinions on this :-)
Regards,
--
Eiríkur Hjartarson
deCODE genetics
Sturlugötu 7
IS-101 Reykjavík
example
Description: example
service
Description: service
--
http://mail.python.org/mailman/listinfo/python-list