diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-07-15 00:14:32 +0200 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-07-17 14:55:38 -0700 |
commit | 971915e89f1106444453eba39263ade92b3ed598 (patch) | |
tree | 0c035289b56faebb100cd0fc5c7f8d644ac39f8f /test/pseudo-tty | |
parent | 19618bd6f54a6f813464fbd4bea7b024ec16677d (diff) | |
download | node-new-971915e89f1106444453eba39263ade92b3ed598.tar.gz |
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: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'test/pseudo-tty')
-rw-r--r-- | test/pseudo-tty/pty_helper.py | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/test/pseudo-tty/pty_helper.py b/test/pseudo-tty/pty_helper.py index d0a4b945d9..bf62e3f205 100644 --- a/test/pseudo-tty/pty_helper.py +++ b/test/pseudo-tty/pty_helper.py @@ -44,42 +44,42 @@ if __name__ == '__main__': # 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: os.setsid() - os.close(master_fd) + os.close(parent_fd) # Ensure the pty is a controlling tty. - name = os.ttyname(slave_fd) + name = os.ttyname(child_fd) fd = os.open(name, os.O_RDWR) - os.dup2(fd, slave_fd) + os.dup2(fd, child_fd) os.close(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: - os.close(slave_fd) + if child_fd > STDERR: + os.close(child_fd) os.execve(argv[0], argv, os.environ) raise Exception('unreachable') - os.close(slave_fd) + os.close(child_fd) - fds = [STDIN, master_fd] + fds = [STDIN, parent_fd] while fds: try: rfds, _, _ = select.select(fds, [], []) @@ -90,9 +90,9 @@ if __name__ == '__main__': break if STDIN in rfds: - if pipe(STDIN, master_fd): + if pipe(STDIN, parent_fd): fds.remove(STDIN) - if master_fd in rfds: - if pipe(master_fd, STDOUT): + if parent_fd in rfds: + if pipe(parent_fd, STDOUT): break |