From 9279bbbd193d449abd8bc1997d7cc18567c98d6b Mon Sep 17 00:00:00 2001 From: Bananymous Date: Fri, 28 Jul 2023 18:10:09 +0300 Subject: [PATCH] Kernel: TTY now sends SIGINT on ^C to foreground process --- kernel/kernel/Terminal/TTY.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/kernel/kernel/Terminal/TTY.cpp b/kernel/kernel/Terminal/TTY.cpp index 8bf2c4a6..d52e39dc 100644 --- a/kernel/kernel/Terminal/TTY.cpp +++ b/kernel/kernel/Terminal/TTY.cpp @@ -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 );