https://github.com/python/cpython/commit/2a41f35ebdef47b5e26aae40977ea196bfbf4de5 commit: 2a41f35ebdef47b5e26aae40977ea196bfbf4de5 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: serhiy-storchaka <[email protected]> date: 2026-07-21T17:47:42+03:00 summary:
[3.13] gh-154345: Fix test_posix_pty_functions() killing the worker on Solaris (GH-154346) (GH-154356) Pushing the "ptem" STREAMS module makes a session leader without a controlling terminal acquire the slave as one, so closing the file descriptors sent SIGHUP to the session and killed the regrtest worker. Disown it after the pushes, as os.openpty() does. (cherry picked from commit f69f7fd526b6601a74ce0852c75466a183a86cea) Co-authored-by: Serhiy Storchaka <[email protected]> Co-authored-by: Claude Opus 4.8 <[email protected]> files: M Lib/test/test_os.py diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 50f6b09b1ee4cc..9b6a05fdbe25e8 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -4789,12 +4789,27 @@ def test_posix_pty_functions(self): son_fd = os.open(son_path, os.O_RDWR|os.O_NOCTTY) self.addCleanup(os.close, son_fd) if sys.platform.startswith('sunos'): - # The slave is not a terminal until these STREAMS modules - # are pushed onto it. import fcntl I_PUSH = 0x5302 + TIOCNOTTY = 0x7471 + # Pushing "ptem" makes the slave a terminal, which a session + # leader without a controlling terminal then acquires as one + # despite O_NOCTTY. Note whether we already had one. + try: + os.close(os.open('/dev/tty', os.O_RDONLY|os.O_NOCTTY)) + had_ctty = True + except OSError: + had_ctty = False fcntl.ioctl(son_fd, I_PUSH, b'ptem\0') fcntl.ioctl(son_fd, I_PUSH, b'ldterm\0') + if not had_ctty and os.getsid(0) == os.getpid(): + # Disown it, otherwise closing the file descriptors sends + # SIGHUP to the session. TIOCNOTTY sends it too. + old_handler = signal.signal(signal.SIGHUP, signal.SIG_IGN) + try: + fcntl.ioctl(son_fd, TIOCNOTTY) + finally: + signal.signal(signal.SIGHUP, old_handler) self.assertEqual(os.ptsname(mother_fd), os.ttyname(son_fd)) @unittest.skipUnless(hasattr(os, 'spawnl'), "need os.spawnl()") _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
