From 6f683c48f081f8009b560dfc3f3addabda0b6be7 Mon Sep 17 00:00:00 2001 From: apio Date: Mon, 18 Sep 2023 07:21:06 +0200 Subject: [PATCH] terminal: Send signals on ^C and ^\ --- terminal/TerminalWidget.cpp | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/terminal/TerminalWidget.cpp b/terminal/TerminalWidget.cpp index e87b8e4d..792938bb 100644 --- a/terminal/TerminalWidget.cpp +++ b/terminal/TerminalWidget.cpp @@ -135,14 +135,9 @@ Result TerminalWidget::handle_key_event(const ui::KeyEventReque { if (!(m_settings.c_lflag & NOFLSH)) m_line_buffer.clear(); - // FIXME: Send SIGINT. - /*if (m_foreground_process_group.has_value()) - { - Scheduler::for_each_in_process_group(m_foreground_process_group.value(), [](Thread* thread) { - thread->send_signal(SIGINT); - return true; - }); - }*/ + pid_t group = tcgetpgrp(m_pty); + TRY(os::Process::kill(-group, SIGINT)); + is_special_character = true; } @@ -150,14 +145,9 @@ Result TerminalWidget::handle_key_event(const ui::KeyEventReque { if (!(m_settings.c_lflag & NOFLSH)) m_line_buffer.clear(); - // FIXME: Send SIGINT. - /*if (m_foreground_process_group.has_value()) - { - Scheduler::for_each_in_process_group(m_foreground_process_group.value(), [](Thread* thread) { - thread->send_signal(SIGQUIT); - return true; - }); - }*/ + pid_t group = tcgetpgrp(m_pty); + TRY(os::Process::kill(-group, SIGQUIT)); + is_special_character = true; } } @@ -598,5 +588,5 @@ void TerminalWidget::put_code_point(wchar_t c) void TerminalWidget::quit() { - kill(m_child_pid, SIGHUP); + kill(-tcgetpgrp(m_pty), SIGHUP); }