Hi, I'm observing some weird behavior and have written the following test program to demonstrate. This works under cygwin/WinXP but not Gentoo(kernel 2.6):
huh.py ------------------------------------------- import pty,os,sys # Fork ( pid, fd ) = pty.fork() if pid == 0: # Child thread print 'Have a happy day!' print 'Forza Azzurri!' else: # Controlling process # read stdout from child process # and send to stderr stream = os.fdopen( fd ) line = stream.readline() while len( line ) > 0: sys.stderr.write(line) line = stream.readline() stream.close() ------------------------------------------- This program runs perfectly under cygwin on Windows XP using python 2.4.3: ======================================================================== [EMAIL PROTECTED] ~/proj/plum $ python huh.py Have a happy day! Forza Azzurri! [EMAIL PROTECTED] ~/proj/plum $ python huh.py 2>/dev/null [EMAIL PROTECTED] ~/proj/plum $ python Python 2.4.3 (#1, May 18 2006, 07:40:45) [GCC 3.3.3 (cygwin special)] on cygwin Type "help", "copyright", "credits" or "license" for more information. >>> [EMAIL PROTECTED] ~/proj/plum $ ======================================================================== But on Gentoo (2.6 kernel) with Python 2.4.3 it dies with an I/O error when it hits the end of the stream: ======================================================================== [EMAIL PROTECTED] ~/proj/plum $ python huh.py Have a happy day! Forza Azzurri! Traceback (most recent call last): File "huh.py", line 19, in ? line = stream.readline() IOError: [Errno 5] Input/output error [EMAIL PROTECTED] ~/proj/plum $ python huh.py 2>/dev/null [EMAIL PROTECTED] ~/proj/plum $ python Python 2.4.3 (#1, Jul 13 2006, 23:02:30) [GCC 3.3.6 (Gentoo 3.3.6, ssp-3.3.6-1.0, pie-8.7.8)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> ======================================================================== Anybody have any idea what's going on here? Is there a better way to fork and capture the output of the child process? Thanks, Chris -- http://mail.python.org/mailman/listinfo/python-list