]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commit
Fix job control TIOCSPGRP: allow session leader to claim TTY/PTY
authorTulio A M Mendes <[email protected]>
Fri, 17 Apr 2026 21:46:32 +0000 (18:46 -0300)
committerTulio A M Mendes <[email protected]>
Fri, 17 Apr 2026 21:46:32 +0000 (18:46 -0300)
commit14c06366895af067d50c336eca5ff2d1cf6bb8e3
tree7ab893a4823550ae6b88a9aafd6382f39477497c
parentf16a76efc1de90ff4f71c970d7d4e0e42bb6ba7b
Fix job control TIOCSPGRP: allow session leader to claim TTY/PTY

When fulltest runs from the shell, the TTY's tty_session_id is already
set to the shell's session. The test's leader child calls setsid() then
TIOCSPGRP, which fails with EPERM because the new session doesn't match
tty_session_id. The kernel never allowed a new session leader to claim
the TTY as its controlling terminal.

Fix: in TIOCSPGRP handler for both tty.c and pty.c, allow a session
leader (session_id == pid) to claim the terminal by updating the
session when it explicitly sets its own pgrp as foreground. This
matches POSIX semantics where a session leader may establish a new
controlling terminal.

Test results: 103/103 smoke test PASS, 16/16 battery PASS.
src/kernel/pty.c
src/kernel/tty.c