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 <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 72f9229 commit af6608c

1 file changed

Lines changed: 17 additions & 17 deletions

File tree

‎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, lambdanr, _: None)
4646

47-
master_fd, slave_fd=pty.openpty()
48-
assertmaster_fd>STDIN
47+
parent_fd, child_fd=pty.openpty()
48+
assertparent_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
ifnotpid:
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-
ifslave_fd>STDERR:
75-
os.close(slave_fd)
74+
ifchild_fd>STDERR:
75+
os.close(child_fd)
7676

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

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

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

9292
ifSTDINinrfds:
93-
ifpipe(STDIN, master_fd):
93+
ifpipe(STDIN, parent_fd):
9494
fds.remove(STDIN)
9595

96-
ifmaster_fdinrfds:
97-
ifpipe(master_fd, STDOUT):
96+
ifparent_fdinrfds:
97+
ifpipe(parent_fd, STDOUT):
9898
break

0 commit comments

Comments
 (0)