This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author luis@luispedro.org
Recipients luis@luispedro.org
Date 2007-09-11.18:03:46
SpamBayes Score 0.5083207
Marked as misclassified No
Message-id <1189533826.38.0.958954232674.issue1149@psf.upfronthosting.co.za>
In-reply-to
Content
from os import *

def Fork():
    b = fork()
    if b < 0:
        raise Exception('fork() failed')
    return b


r,w=pipe()
b = Fork()
if b == 0:
   dup2(w,1)
   close(w)
   execlp('echo',\
       'echo',\
        'Hello world')
else:
   for line in fdopen(r):
       print 'Read %s' % line

I was expecting this code to print "Read Hello World". Instead, it 
hangs forever.

Changing "for line in fdopen(r): print 'Read %s' % line" 
to "line=read(r,100); print 'Read %s' % line" makes the program work 
as expected. This is what I did on my actual production code, but it 
seems funny behaviour on the part of fdopen.

I am running on Ubuntu on PowerPC.
History
Date User Action Args
2007-09-11 18:03:46luis@luispedro.orgsetspambayes_score: 0.508321 -> 0.5083207
recipients: + luis@luispedro.org
2007-09-11 18:03:46luis@luispedro.orgsetspambayes_score: 0.508321 -> 0.508321
messageid: <1189533826.38.0.958954232674.issue1149@psf.upfronthosting.co.za>
2007-09-11 18:03:46luis@luispedro.orglinkissue1149 messages
2007-09-11 18:03:46luis@luispedro.orgcreate