[Python-bugs-list] [ python-Bugs-514345 ] pty.fork problem
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 08 Feb 2002 13:58:52 -0800
Bugs item #514345, was opened at 2002-02-07 08:21
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=514345&group_id=5470
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: M.-A. Lemburg (lemburg)
>Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: pty.fork problem
Initial Comment:
Subject:
Python bugreport, pty.fork problem
Date:
Thu, 07 Feb 2002 07:30:08 -0800
From:
Ronald Oussoren <oussoren@cistron.nl>
To:
mal@lemburg.com
Sorry about the e-mail, but the bugtracker on SF doesn't
accept my bugreport (I don't have a SF account).
The following script never returns:
----------------- start of script -------------
import pty
import os
import sys
def test():
pid, fd = pty.fork()
if pid == 0:
print "1"
print "2"
print "3"
else:
fp = os.fdopen(fd, 'r')
ln = fp.readline()
while ln:
print '-->', ln
ln = fp.readline()
print '-->', ln
test()
------------------ end of script -----------------
It prints '-->1' to '-->3' and then blocks.
I've tested this with python 2.1 on Solaris 8. On Solaris
pty.open seems to use 'openpty' instead of 'os.openpty'. A
2-line change fixed the problem for me, but not for this
demo-script: Close 'slave_fd' when pid != CHILD.
----------------------------------------------------------------------
>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-02-08 13:58
Message:
Logged In: YES
user_id=6380
Assigning to Fred, who appears to have hacked this module
before.
I cannot reproduce the problem, but I see a different
problem that may be hinting at the same issue:
Under Python 2.1 or before, on Red Hat Linux 7.2, the test
program for me prints this:
--> 1
--> 2
--> 3
-->
and exits. But with Python 2.2, it prints:
--> 1
--> 2
--> 3
Traceback (most recent call last):
File "/tmp/tpty.py", line 20, in ?
test()
File "/tmp/tpty.py", line 17, in test
ln = fp.readline()
IOError: [Errno 5] Input/output error
How can the difference be explained? I like the pre-2.2
behavior better!
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=514345&group_id=5470