Subprocess troubles from a daemon

2012-04-13 Thread Eiríkur Hjartarson
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


RE: Subprocess troubles from a daemon

2012-04-13 Thread Eiríkur Hjartarson
Hi,

> -Original Message-
> From: python-list-bounces+eirikur.hjartarson=decode...@python.org
> [mailto:python-list-bounces+eirikur.hjartarson=decode...@python.org] On
> Behalf Of Terry Reedy
> Sent: 13. apríl 2012 14:57
> To: python-list@python.org
> Subject: Re: Subprocess troubles from a daemon
> 
> On 4/13/2012 7:04 AM, Eiríkur Hjartarson wrote:
> > 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.
> 
> What happens is you use the new 2.7.3 release? It has hundreds of bug
> fixes not in 2.6.x.

I don't have access to 2.7.3-python, but I tried it on 2.7.2, and there the bug 
is fixed.

> --
> Terry Jan Reedy

Thanks,
-- 
Eiríkur Hjartarson
deCODE genetics
Sturlugötu 7
IS-101 Reykjavík
-- 
http://mail.python.org/mailman/listinfo/python-list