From 40aa6876011d043a1950dfa9867a6d4da378b733 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 17 Aug 2020 19:56:00 +1000 Subject: [PATCH] Do not fork in daemon mode Leave that to the shell or external service management tools Fixes #3618 --- doc/pages/changelog.asciidoc | 4 ++++ src/main.cc | 19 ++++++------------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/doc/pages/changelog.asciidoc b/doc/pages/changelog.asciidoc index e7b10d6a..5727765d 100644 --- a/doc/pages/changelog.asciidoc +++ b/doc/pages/changelog.asciidoc @@ -3,6 +3,10 @@ This changelog contains major and/or breaking changes to Kakoune between released versions. +== Development version + +* Daemon mode (`-d` switch) does not fork anymore. + == Kakoune 2020.08.04 * Introduce `User` hook support. diff --git a/src/main.cc b/src/main.cc index 76fa64ec..0b56064a 100644 --- a/src/main.cc +++ b/src/main.cc @@ -44,6 +44,9 @@ struct { unsigned int version; StringView notes; } constexpr version_notes[] = { { + 0, + "» daemon mode does not fork anymore\n" + }, { 20200804, "» {+u}User{} hook support\n" "» Removed {+i}bold{} and {+i}italic{} faces from colorschemes\n" @@ -727,20 +730,10 @@ int run_server(StringView session, StringView server_init, { static bool terminate = false; set_signal_handler(SIGTERM, [](int) { terminate = true; }); - if (flags & ServerFlags::Daemon) + if ((flags & ServerFlags::Daemon) and session.empty()) { - if (session.empty()) - { - write_stderr("-d needs a session name to be specified with -s\n"); - return -1; - } - if (pid_t child = fork()) - { - write_stderr(format("Kakoune forked to background, for session '{}'\n" - "send SIGTERM to process {} for closing the session\n", - session, child)); - exit(0); - } + write_stderr("-d needs a session name to be specified with -s\n"); + return -1; } EventManager event_manager;