Bug report
On illumos/Solaris, os.openpty() leaves the calling process with the new pty as its controlling terminal, despite opening the slave with O_NOCTTY. The ptem STREAMS module that openpty() pushes turns the slave into a terminal, and a session leader without a controlling terminal then acquires it at push time.
This causes the whole pty-based test cluster (test_readline, test_cmd, test_pty, ...) to hang forever under python -m test -jN, because regrtest workers are session leaders: after pty_helper.run_pty's child exits, the controlling-terminal association keeps the slave open, so the master never reaches EOF.
After pushing the STREAMS modules, disown a newly-acquired controlling terminal with TIOCNOTTY (with SIGHUP ignored, since it is sent to the session leader).
Linked PRs
- gh-154225: Fix os.openpty() acquiring a controlling terminal on Solaris #154229
- [3.15] gh-154225: Fix os.openpty() acquiring a controlling terminal on Solaris (GH-154229) #154238
- [3.14] gh-154225: Fix os.openpty() acquiring a controlling terminal on Solaris (GH-154229) #154256
- [3.13] gh-154225: Fix os.openpty() acquiring a controlling terminal on Solaris (GH-154229) #154257