Skip to content

Commit af6608c

Browse files
addaleaxtargos
authored andcommitted
test: improve variable names in pty_helper.py
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 <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent 72f9229 commit af6608c

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

test/pseudo-tty/pty_helper.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,42 +44,42 @@ def pipe(sfd, dfd):
4444
# Make select() interruptable by SIGCHLD.
4545
signal.signal(signal.SIGCHLD, lambda nr, _: None)
4646

47-
master_fd, slave_fd = pty.openpty()
48-
assert master_fd > STDIN
47+
parent_fd, child_fd = pty.openpty()
48+
assert parent_fd > STDIN
4949

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

5959
pid = os.fork()
6060
if not pid:
6161
os.setsid()
62-
os.close(master_fd)
62+
os.close(parent_fd)
6363

6464
# Ensure the pty is a controlling tty.
65-
name = os.ttyname(slave_fd)
65+
name = os.ttyname(child_fd)
6666
fd = os.open(name, os.O_RDWR)
67-
os.dup2(fd, slave_fd)
67+
os.dup2(fd, child_fd)
6868
os.close(fd)
6969

70-
os.dup2(slave_fd, STDIN)
71-
os.dup2(slave_fd, STDOUT)
72-
os.dup2(slave_fd, STDERR)
70+
os.dup2(child_fd, STDIN)
71+
os.dup2(child_fd, STDOUT)
72+
os.dup2(child_fd, STDERR)
7373

74-
if slave_fd > STDERR:
75-
os.close(slave_fd)
74+
if child_fd > STDERR:
75+
os.close(child_fd)
7676

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

80-
os.close(slave_fd)
80+
os.close(child_fd)
8181

82-
fds = [STDIN, master_fd]
82+
fds = [STDIN, parent_fd]
8383
while fds:
8484
try:
8585
rfds, _, _ = select.select(fds, [], [])
@@ -90,9 +90,9 @@ def pipe(sfd, dfd):
9090
break
9191

9292
if STDIN in rfds:
93-
if pipe(STDIN, master_fd):
93+
if pipe(STDIN, parent_fd):
9494
fds.remove(STDIN)
9595

96-
if master_fd in rfds:
97-
if pipe(master_fd, STDOUT):
96+
if parent_fd in rfds:
97+
if pipe(parent_fd, STDOUT):
9898
break

0 commit comments

Comments
 (0)