The pts driver has an issue with breaking the promise made by select() that a read will not block, if there is a write of ^S to the pty between the select() and the read(). The reproduction for this is very simple: script /dev/null yes Type ^S. Type ^Q. Nothing happens, because script is hung on a blocking read. The read will never complete, because script is hung and your ^Q will never be delivered. I originally discovered this while working on mosh (net/mosh), but script blocks in the same way. The sequence of events that causes this: * The pty slave has software flow control enabled. * select() returns read status for the pty master fd. * Something write()s ^S to the pty master. * A read() is started on the pty master, with the expectation that it will not block. But it does block, and since the tty is stopped, it will never unblock without outside intervention. I hesitate to call this a bug, because the state of the pty *is* changed by that write, and the fix for this issue is not clear. But it violates POLA, other kernels (Linux, OpenBSD) do not behave this way, and the consequences are serious. I see this issue on FreeBSD 10.2, 9.1, and 7.2. An old 4.10 box doesn't have this issue. I originally discovered this bug while working on Mosh. It's not a new bug there. I've now implemented pty packet mode, and the problem exists there too, even though packet mode should always be able to avoid breaking this promise. See https://github.com/mobile-shell/mosh/issues/692 https://github.com/cgull/mosh/tree/pty-packet I don't understand why nobody has run into this issue before though, either on the FreeBSD or on the Mosh side. (Mosh has this problem on FreeBSD and OS X.)
I can reproduce this using script on stable/10 and head (all amd64).
Still present on 12.0p2.