Quit server on SIGINT when it was not signaled by Kakoune itself

Fixes #3974
This commit is contained in:
Maxime Coste 2021-07-12 10:08:17 +10:00
parent c30a0e0ca2
commit 7622ebcc92
2 changed files with 5 additions and 0 deletions

View File

@ -47,7 +47,11 @@ Client::Client(std::unique_ptr<UserInterface>&& ui,
m_ui->set_ui_options(m_window->options()["ui_options"].get<UserInterface::Options>());
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());

View File

@ -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");