From 6f9f80c11284ec3e4a2fdb81a60b5167a6026dd2 Mon Sep 17 00:00:00 2001 From: Marcos Mello Date: Wed, 7 Feb 2018 07:55:42 -0200 Subject: [PATCH] Signal systemd on daemon start systemd service files run in no forking mode (--foreground) since 8b6f58194da7e849cdb9d20712dff49b17a93a77. Rearrange sd_notify() call in become_daemon() to only signal systemd in this mode (Type=notify is not designed to monitor double forking). Also drop READY=0 (it does nothing) and MAINPID= (unnecessary because the process spawned by systemd is already the main PID). Signed-off-by: Marcos Mello --- lib/util/become_daemon.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/util/become_daemon.c b/lib/util/become_daemon.c index 232eda69b64..3b6a4bb11ed 100644 --- a/lib/util/become_daemon.c +++ b/lib/util/become_daemon.c @@ -73,14 +73,12 @@ void become_daemon(bool do_fork, bool no_session, bool log_stdout) exit_daemon("Fork failed", errno); } if (newpid) { -#if defined(HAVE_LIBSYSTEMD_DAEMON) || defined(HAVE_LIBSYSTEMD) - sd_notifyf(0, - "READY=0\nSTATUS=Starting process...\n" - "MAINPID=%lu", - (unsigned long) newpid); -#endif /* HAVE_LIBSYSTEMD_DAEMON */ _exit(0); } +#if defined(HAVE_LIBSYSTEMD_DAEMON) || defined(HAVE_LIBSYSTEMD) + } else { + sd_notify(0, "STATUS=Starting process..."); +#endif /* HAVE_LIBSYSTEMD_DAEMON */ } /* detach from the terminal */ -- 2.16.1