This patch comes from an issue discovered in systemd, where it can fail to restore a text TTY session after a GUI session is stopped when compiled with musl libc. The specific systemd integration issue is currently resolved in the musl master branch by closer aligning the implementation with glibc, but the underlying isatty() implementation is still flawed since it can return 0 (false) for something that is definitely a TTY. Essentially both musl and glibc give up correctly handling this case on Linux due to inadequate/buggy kernel APIs. Thus I am proposing this patch as a solution to fix the kernel APIs. An alternative fix could be to add a new IOCTL to specifically handle this, but that seems overkill. Link: https://github.com/systemd/systemd/pull/34039 Link: https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/70711 Link: https://www.openwall.com/lists/musl/2024/08/20/2 Link: https://git.musl-libc.org/cgit/musl/commit/src/unistd/isatty.c?id=c94a0c16f08894ce3be6dafb0fe80baa77a6ff2a Link: https://sourceware.org/bugzilla/show_bug.cgi?id=32103 Gil Pedersen (1): tty: respond to TIOCGWINSZ when hung drivers/tty/tty_io.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) -- 2.45.2