tty: internal mode state does not account for changes outside of libuv
Author: wavexxCreated Apr 7, 2017Updated Jun 3, 2026
Labelsstale
When changing the tty mode (via uv_tty_set_mode), we keep an internal "mode" state to avoid doing ioctls again. I see this is used to restore the original terminal mode, but it introduces some issues.
When using a pty to control a slave process, the slave might change the mode on our back. I have this problem on a couple of occasions, where I need to force a call to cfmakeraw() but I need to toggle the internal state (by changing the tty mode to NORMAL and then IO again) to actually do it.
I'd be tempted to add a "force" parameter to always set the requested mode, but maybe there's a better solution?
Source: libuv/libuv