Closed alexrp closed 2 years ago
One option would be to compare the current termios
values to our desired values and only call tcsetattr
if they differ.
The obvious downsides here are:
But what about the times when the foreground process is in raw mode and we end up completely garbling the screen?
Such an application should really set TOSTOP
(which we would be forced to respect as we can't block/ignore SIGTTOU
from managed land anyway). See:
I think I'm satisfied that there would be no major issues with just assuming we're in cooked mode. I think it's entirely reasonable to say that if a parent process launches a child process in raw mode, the developer of the parent process is doing it wrong. Nobody expects their program to launch in raw mode.
Currently, when we call
tcsetattr
during driver initialization to ensure we're in cooked mode, we can be suspended by aSIGTTOU
if we're a background process. The question is: Should we handleSIGTTOU
instead (so that we don't get suspended) and just proceed, trusting that the terminal is probably in cooked mode?Arguably, this is probably fine most of the time. But what about the times when the foreground process is in raw mode and we end up completely garbling the screen? I'm not sure there's really a 'correct' answer. Need to think more on this.
Useful reference: http://curiousthing.org/sigttin-sigttou-deep-dive-linux