Make it possible for a process to switch controlling terminals.

Via the TIOCSCTTY and TIOCNOTTY ioctls.
This commit is contained in:
Andreas Kling 2019-01-15 08:49:24 +01:00
commit 49b63281a0
Notes: sideshowbarker 2024-07-19 16:02:10 +09:00
6 changed files with 31 additions and 4 deletions

View file

@ -107,7 +107,7 @@ int TTY::ioctl(Process& process, unsigned request, unsigned arg)
Unix::termios* tp;
Unix::winsize* ws;
if (process.tty() != this)
if (process.tty() && process.tty() != this)
return -ENOTTY;
switch (request) {
case TIOCGPGRP:
@ -140,6 +140,12 @@ int TTY::ioctl(Process& process, unsigned request, unsigned arg)
ws->ws_row = m_rows;
ws->ws_col = m_columns;
return 0;
case TIOCSCTTY:
process.set_tty(this);
return 0;
case TIOCNOTTY:
process.set_tty(nullptr);
return 0;
}
ASSERT_NOT_REACHED();
return -EINVAL;