mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 08:28:11 +00:00
Make it possible for a process to switch controlling terminals.
Via the TIOCSCTTY and TIOCNOTTY ioctls.
This commit is contained in:
parent
10308c6434
commit
49b63281a0
6 changed files with 31 additions and 4 deletions
|
@ -206,6 +206,7 @@ public:
|
|||
static int reap(Process&) WARN_UNUSED_RESULT;
|
||||
|
||||
const TTY* tty() const { return m_tty; }
|
||||
void set_tty(TTY* tty) { m_tty = tty; }
|
||||
|
||||
size_t regionCount() const { return m_regions.size(); }
|
||||
const Vector<RetainPtr<Region>>& regions() const { return m_regions; }
|
||||
|
|
|
@ -5,6 +5,7 @@ SlavePTY::SlavePTY(unsigned index)
|
|||
: TTY(11, index)
|
||||
, m_index(index)
|
||||
{
|
||||
set_size(80, 25);
|
||||
}
|
||||
|
||||
SlavePTY::~SlavePTY()
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue