From: Sven Eden Date: Wed, 30 Aug 2017 08:59:42 +0000 (+0200) Subject: Prep v235: Do not write an early PID file, if elogind is going to be daemonized. X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=3fa6fe72a6dff725f8c9f26f981b789ae721596a;p=elogind.git Prep v235: Do not write an early PID file, if elogind is going to be daemonized. --- diff --git a/src/login/elogind.c b/src/login/elogind.c index 0dace0eff..1592e0e94 100644 --- a/src/login/elogind.c +++ b/src/login/elogind.c @@ -120,7 +120,7 @@ static int elogind_daemonize(void) { /// Simple tool to see, if elogind is already running -static pid_t elogind_is_already_running(void) { +static pid_t elogind_is_already_running(bool need_pid_file) { _cleanup_free_ char *s = NULL; pid_t pid; int r; @@ -143,7 +143,8 @@ we_are_alone: /* Take care of our PID-file now. If the user is going to fork elogind, the PID file will be overwritten. */ - write_pid_file(); + if (need_pid_file) + write_pid_file(); return 0; } @@ -293,9 +294,9 @@ int elogind_startup(int argc, char *argv[]) { } /* Do not continue if elogind is already running */ - pid = elogind_is_already_running(); + pid = elogind_is_already_running(!daemonize); if (pid) { - fprintf(stderr, "elogind is already running:" PID_FMT "\n", pid); + fprintf(stderr, "elogind is already running as PID " PID_FMT "\n", pid); return pid; }