]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commit
libgloss: fix isatty() and ttyname() — use TCGETS instead of TIOCGPGRP with NULL
authorTulio A M Mendes <[email protected]>
Sun, 19 Apr 2026 21:05:46 +0000 (18:05 -0300)
committerTulio A M Mendes <[email protected]>
Sun, 19 Apr 2026 21:05:46 +0000 (18:05 -0300)
commita1771488db7a7e3b587e93ca661b7128fbfaa07e
treebb6a65b96d95de71f3ae9a6e9524faf3ee02f26f
parenteb03cb28a74308a0f9b33ae7034eb771c4bf1ee6
libgloss: fix isatty() and ttyname() — use TCGETS instead of TIOCGPGRP with NULL

isatty() in syscalls.c used ioctl(TIOCGPGRP, 0) which always failed
because the kernel rejects NULL user_arg with -EFAULT. This caused
bash to think stdin was not a terminal, running in non-interactive
mode (no prompt, no line editing).

Fix: use TCGETS (0x5401) with a stack-allocated termios struct instead.
TCGETS succeeds on any tty regardless of process group state — this
is the standard POSIX way to test for a terminal.

Also fix ttyname() in posix_stubs.c which had the same bug.
newlib/libgloss/adros/posix_stubs.c
newlib/libgloss/adros/syscalls.c