From ff4ef994c46ee3d7db80c4f81c211907a24e2cb4 Mon Sep 17 00:00:00 2001 From: M Felt aka aixtools Date: Thu, 2 Apr 2020 17:36:09 +0000 Subject: [PATCH] Stop `test_builtin` from hanging on AIX, Solaris and maybe others. This is to workaround a side-effect introduced by 16d75675d2ad2454f6dfbf333c94e6237df36018 bpo-31160: Fix race condition in test_os.PtyTests (GH-19263) Patch by M. Felt --- Lib/test/test_builtin.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index eaada1b50439be..4a5addc6fe9e57 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -1893,12 +1893,18 @@ def run_child(self, child, terminal_input): self.fail("got %d lines in pipe but expected 2, child output was:\n%s" % (len(lines), child_output)) - # Wait until the child process completes before closing the PTY to - # prevent sending SIGHUP to the child process. - support.wait_process(pid, exitcode=0) + if sys.platform == "linux" or not os.name == "posix": + # Wait until the child process completes before closing the PTY to + # prevent sending SIGHUP to the child process. + support.wait_process(pid, exitcode=0) - # Close the PTY - os.close(fd) + # Close the PTY + os.close(fd) + else: + # Other posix need to close the pty for the child to exit normally + # Close the PTY + os.close(fd) + support.wait_process(pid, exitcode=0) return lines