[Patches] [ python-Patches-783050 ] pty.fork() compatibility code wrong?
SourceForge.net
noreply at sourceforge.net
Fri Dec 22 19:42:44 CET 2006
Patches item #783050, was opened at 2003-08-04 16:02
Message generated for change (Comment added) made by akuchling
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=783050&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
>Category: Library (Lib)
Group: None
>Status: Closed
>Resolution: Accepted
Priority: 5
Private: No
Submitted By: Patrick Lynch (rvdp)
>Assigned to: A.M. Kuchling (akuchling)
Summary: pty.fork() compatibility code wrong?
Initial Comment:
pty.fork() provides compatibility code for environments
lacking os.forkpty()
This code is incorrect compared to the forkpty code in glibc,
and will cause reading of the returned master_fd to hang
indefinetly when the child process is finished.
I am running on linux, Python 2.2. I am using the
compatibility code where I need more control ( grabing
stdout seperate to stderr, which is on the pty).
To have it read like forkpty in glibc:
<snip>
master_fd, slave_fd = openpty()
pid = os.fork()
if pid == CHILD:
# Establish a new session.
os.setsid()
os.close(master_fd)
# Slave becomes stdin/stdout/stderr of child.
os.dup2(slave_fd, STDIN_FILENO)
os.dup2(slave_fd, STDOUT_FILENO)
os.dup2(slave_fd, STDERR_FILENO)
if (slave_fd > STDERR_FILENO):
os.close (slave_fd)
else:#PARENT
os.close( slave_fd)
# Parent and child process.
return pid, master_fd
Reading the master_fd when the child is finished will now
raise an IO error, same as the native forkpty().
I guess the story may be different on non linux boxen
Patrick.
----------------------------------------------------------------------
>Comment By: A.M. Kuchling (akuchling)
Date: 2006-12-22 13:42
Message:
Logged In: YES
user_id=11375
Originator: NO
Applied to the trunk in rev. 53146. Thanks for pointing out this bug!
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=783050&group_id=5470
More information about the Patches
mailing list