From 88f51f75b347f81b20dd22ed910a6aae76f8faab Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Sun, 13 Feb 2022 07:51:03 +0100 Subject: [PATCH] #21 Also setsid on second fork, systemd seems to require it --- BaseCommon/Daemon.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/BaseCommon/Daemon.cpp b/BaseCommon/Daemon.cpp index 27978c9..f0d6335 100644 --- a/BaseCommon/Daemon.cpp +++ b/BaseCommon/Daemon.cpp @@ -75,6 +75,10 @@ DAEMONIZE_RESULT CDaemon::daemonize(const std::string& pidFile) return DR_PARENT; } + if (setsid() < 0) { + return DR_FAILURE; + } + /* Set new file permissions */ umask(0);