Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 287d09a

Browse files
committed
Use os.login_tty() in pty.fork() on systems that lack os.forkpty().
Signed-off-by: Soumendra Ganguly <[email protected]>
1 parent ffcb822 commit 287d09a

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

Lib/pty.py

+1-13
Original file line numberDiff line numberDiff line change
@@ -101,20 +101,8 @@ def fork():
101101
master_fd, slave_fd = openpty()
102102
pid = os.fork()
103103
if pid == CHILD:
104-
# Establish a new session.
105-
os.setsid()
106104
os.close(master_fd)
107-
108-
# Slave becomes stdin/stdout/stderr of child.
109-
os.dup2(slave_fd, STDIN_FILENO)
110-
os.dup2(slave_fd, STDOUT_FILENO)
111-
os.dup2(slave_fd, STDERR_FILENO)
112-
if slave_fd > STDERR_FILENO:
113-
os.close(slave_fd)
114-
115-
# Explicitly open the tty to make it become a controlling tty.
116-
tmp_fd = os.open(os.ttyname(STDOUT_FILENO), os.O_RDWR)
117-
os.close(tmp_fd)
105+
os.login_tty(slave_fd)
118106
else:
119107
os.close(slave_fd)
120108

0 commit comments

Comments
 (0)