[issue1149] fdopen does not work as expected

2007-09-17 Thread Sean Reifschneider

Sean Reifschneider added the comment:

I do not believe this is a Python problem but instead a problem with
your code.  I believe the problem is likely that you still have a copy
of the stdout is open, the fork that is reading also gets associated
with that same file.  I can't point you at any specific references, but
you should check Posix references or possibly other sources for more
information about side-effects such as this.

These interactions, I have found, can be pretty subtle, so you may need
to spend some time on getting everything right.

--
nosy: +jafo
resolution:  -> invalid
status: open -> closed

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1149] fdopen does not work as expected

2007-09-11 Thread Luís Pedro Coelho

New submission from Luís Pedro Coelho:

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.

--
components: Library (Lib)
messages: 55829
nosy: [EMAIL PROTECTED]
severity: normal
status: open
title: fdopen does not work as expected
type: behavior
versions: Python 2.3, Python 2.4, Python 2.5

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com