Kernel: TTY now sends SIGINT on ^C to foreground process

This commit is contained in:
Bananymous 2023-07-28 18:10:09 +03:00
parent 5652af3384
commit a5813f9ba5
1 changed files with 14 additions and 1 deletions

View File

@ -73,7 +73,20 @@ namespace Kernel
{
Input::KeyEvent event;
ASSERT(MUST(Process::current().sys_read(fd, &event, sizeof(event))) == sizeof(event));
TTY::current()->on_key(event);
TTY& current_tty = *TTY::current();
if (current_tty.m_foreground_process &&
event.pressed() &&
event.ctrl() &&
!event.shift()
&& event.key == Input::Key::C
)
{
if (auto ret = Process::sys_kill(current_tty.m_foreground_process, SIGINT); ret.is_error())
dwarnln("TTY: {}", ret.error());
}
else
current_tty.on_key(event);
}
}, nullptr
);