Skip to content
Browse files

test: improve variable names in

Using names like `parent_fd` and `child_fd` is more accurate here,
and doesn’t come with unnecessary negative connotations, even if
the previous naming is somewhat common terminology here.

PR-URL: #28688
Reviewed-By: Rich Trott <>
Reviewed-By: Colin Ihrig <>
Reviewed-By: James M Snell <>
Reviewed-By: Trivikram Kamat <>
  • Loading branch information...
addaleax authored and Trott committed Jul 14, 2019
1 parent 19618bd commit 971915e89f1106444453eba39263ade92b3ed598
Showing with 17 additions and 17 deletions.
  1. +17 −17 test/pseudo-tty/
@@ -44,42 +44,42 @@ def pipe(sfd, dfd):
# Make select() interruptable by SIGCHLD.
signal.signal(signal.SIGCHLD, lambda nr, _: None)

master_fd, slave_fd = pty.openpty()
assert master_fd > STDIN
parent_fd, child_fd = pty.openpty()
assert parent_fd > STDIN

mode = termios.tcgetattr(slave_fd)
mode = termios.tcgetattr(child_fd)
# Don't translate \n to \r\n.
mode[1] = mode[1] & ~termios.ONLCR # oflag
# Disable ECHOCTL. It's a BSD-ism that echoes e.g. \x04 as ^D but it
# doesn't work on platforms like AIX and Linux. I checked Linux's tty
# driver and it's a no-op, the driver is just oblivious to the flag.
mode[3] = mode[3] & ~termios.ECHOCTL # lflag
termios.tcsetattr(slave_fd, termios.TCSANOW, mode)
termios.tcsetattr(child_fd, termios.TCSANOW, mode)

pid = os.fork()
if not pid:

# Ensure the pty is a controlling tty.
name = os.ttyname(slave_fd)
name = os.ttyname(child_fd)
fd =, os.O_RDWR)
os.dup2(fd, slave_fd)
os.dup2(fd, child_fd)

os.dup2(slave_fd, STDIN)
os.dup2(slave_fd, STDOUT)
os.dup2(slave_fd, STDERR)
os.dup2(child_fd, STDIN)
os.dup2(child_fd, STDOUT)
os.dup2(child_fd, STDERR)

if slave_fd > STDERR:
if child_fd > STDERR:

os.execve(argv[0], argv, os.environ)
raise Exception('unreachable')


fds = [STDIN, master_fd]
fds = [STDIN, parent_fd]
while fds:
rfds, _, _ =, [], [])
@@ -90,9 +90,9 @@ def pipe(sfd, dfd):

if STDIN in rfds:
if pipe(STDIN, master_fd):
if pipe(STDIN, parent_fd):

if master_fd in rfds:
if pipe(master_fd, STDOUT):
if parent_fd in rfds:
if pipe(parent_fd, STDOUT):

0 comments on commit 971915e

Please sign in to comment.
You can’t perform that action at this time.