On Fri, 8 Nov 2024 at 18:49, Brendan Jackman jackmanb@google.com wrote:
Hi all,
Does anyone know what the 'stty sane' invocation in kunit.py is about?
The other day I ran into an issue when running it via watchexec[1]. At the time I believed that it was there to clean up after the firmware that QEMU runs potentially messed up the terminal.
However, I just realised I'm not sure if that makes sense - stty is about setting terminal settings via ioctl. I don't think QEMU or its guests are messing up the terminal with ioctls, they're just writing funny control characters.
What's going on here? I guess one of:
- Terminal is messed up with ctrl chars but ioctls are the
easiest/only way to reliably clean it up.
- Nobody thought about this unimportant detail so hard before and
there's no particular rationale in place here.
- I made bad assumptions about why the `stty sane` is there.
If it's 1 or 2 I wonder if there's an alternative way to clean up without getting the SIGTTOU issue.
Or, maybe it doesn't matter and the fact that this was ever a problem is just a bug in watchexec (maybe you can tell I haven't actually taken the time to research the SIGTTOU thing properly). But thought I'd raise it in case this points to issues people might have using kunit.py in CI.
[1] https://github.com/watchexec/watchexec/issues/874 [2] https://gist.github.com/bjackman/27fd9980d87c5556c20e67a6ed891500
If I remember correctly, this was due to UML sometimes messing up the terminal (not QEMU, though QEMU definitely does the same thing sometimes), possibly just when it terminated uncleanly. It may also have been, as Daniel notes, something to do with the --alltests option, which used allyesconfig, so could enable some strange settings.
We definitely didn't look into things closely enough to determine if it was just control codes, or actual IOCTLs. I suspect it's just control codes, but UML does have some strange TTY options (though I think those don't affect us, as we usually pipe the results though.)
'stty sane' was probably used because it worked, and 'reset' would clear the screen, leaving us without the results visible.
If there's another way which doesn't break anything, I'd be happy to change it. Maybe outputting '\033c' would do it?
-- David