[New-bugs-announce] [issue1149] fdopen does not work as expected

Luís Pedro Coelho report at bugs.python.org
Tue Sep 11 20:03:46 CEST 2007

New submission from Luís Pedro Coelho:

from os import *

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

b = Fork()
if b == 0:
        'Hello world')
   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.

components: Library (Lib)
messages: 55829
nosy: luis at luispedro.org
severity: normal
status: open
title: fdopen does not work as expected
type: behavior
versions: Python 2.3, Python 2.4, Python 2.5

Tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list