Closed
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
% yes | python3 -c "import pty; pty.spawn(['cat'])"
y
...
y^CTraceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.10/pty.py", line 181, in spawn
_copy(master_fd, master_read, stdin_read)
File "/usr/lib/python3.10/pty.py", line 161, in _copy
_writen(master_fd, data)
File "/usr/lib/python3.10/pty.py", line 127, in _writen
n = os.write(fd, data)
KeyboardInterrupt
You will see 2048 lines of y due to tty echo, then the output stops and hangs forever.
Both python and cat block on write, waiting each other consume something from pty buffer.
Your environment
Tested on Linux/macOS with CPython 3.10.
Linked PRs
Metadata
Metadata
Assignees
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
zhangyoufu commentedon Sep 3, 2022
pty._copydid not check whether the destination fd is writable.ambv commentedon Oct 5, 2022
I can reproduce this with
main, and the proposed PR does indeed fix the deadlock.gh-96522: Fix deadlock in pty.spawn (#96639)
[3.11] pythongh-96522: Fix deadlock in pty.spawn (pythonGH-96639)
[3.11] gh-96522: Fix deadlock in pty.spawn (GH-96639) (#104655)
ambv commentedon May 19, 2023
Fixed in 3.11 and 3.12.
ambv commentedon May 19, 2023
Thanks, @zhangyoufu! ✨ 🍰 ✨
Merge branch 'main' into gsallam/main
fix(ci): Remove flaky test_pty from Linux test group