From 7622ebcc92b19cc3615d89f1869cde034e80503d Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 12 Jul 2021 10:08:17 +1000 Subject: [PATCH] Quit server on SIGINT when it was not signaled by Kakoune itself Fixes #3974 --- src/client.cc | 4 ++++ src/main.cc | 1 + 2 files changed, 5 insertions(+) diff --git a/src/client.cc b/src/client.cc index da178623..945b4d2f 100644 --- a/src/client.cc +++ b/src/client.cc @@ -47,7 +47,11 @@ Client::Client(std::unique_ptr&& ui, m_ui->set_ui_options(m_window->options()["ui_options"].get()); m_ui->set_on_key([this](Key key) { if (key == ctrl('c')) + { + auto prev_handler = set_signal_handler(SIGINT, SIG_IGN); killpg(getpgrp(), SIGINT); + set_signal_handler(SIGINT, prev_handler); + } else if (key.modifiers & Key::Modifiers::Resize) { m_window->set_dimensions(key.coord()); diff --git a/src/main.cc b/src/main.cc index eb08a9b7..28de0063 100644 --- a/src/main.cc +++ b/src/main.cc @@ -737,6 +737,7 @@ int run_server(StringView session, StringView server_init, { static bool terminate = false; set_signal_handler(SIGTERM, [](int) { terminate = true; }); + set_signal_handler(SIGINT, [](int) { terminate = true; }); if ((flags & ServerFlags::Daemon) and session.empty()) { write_stderr("-d needs a session name to be specified with -s\n");