mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 23:58:11 +00:00
Kernel: Send SIGTTIN and SIGTTOU signals on background TTY read/write
A process that is not in the foreground process group of a TTY should not be allowed to read/write that TTY. Instead, we now send either a SIGTTIN (on read) or SIGTTOU (on write) signal to the process, and fail the I/O syscall with EINTR. Fixes #205.
This commit is contained in:
parent
771751258e
commit
83e32788d5
1 changed files with 10 additions and 0 deletions
|
@ -54,6 +54,11 @@ void TTY::set_default_termios()
|
|||
|
||||
KResultOr<size_t> TTY::read(FileDescription&, size_t, u8* buffer, size_t size)
|
||||
{
|
||||
if (Process::current()->pgid() != pgid()) {
|
||||
Process::current()->send_signal(SIGTTIN, nullptr);
|
||||
return KResult(-EINTR);
|
||||
}
|
||||
|
||||
if (m_input_buffer.size() < static_cast<size_t>(size))
|
||||
size = m_input_buffer.size();
|
||||
|
||||
|
@ -85,6 +90,11 @@ KResultOr<size_t> TTY::read(FileDescription&, size_t, u8* buffer, size_t size)
|
|||
|
||||
KResultOr<size_t> TTY::write(FileDescription&, size_t, const u8* buffer, size_t size)
|
||||
{
|
||||
if (Process::current()->pgid() != pgid()) {
|
||||
Process::current()->send_signal(SIGTTOU, nullptr);
|
||||
return KResult(-EINTR);
|
||||
}
|
||||
|
||||
on_tty_write(buffer, size);
|
||||
return size;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue