chiark / gitweb /
Prep v235: Do not write an early PID file, if elogind is going to be daemonized.
authorSven Eden <yamakuzure@gmx.net>
Wed, 30 Aug 2017 08:59:42 +0000 (10:59 +0200)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 Aug 2017 08:59:42 +0000 (10:59 +0200)
src/login/elogind.c

index 0dace0eff0cde8f092e6ffe8ab9c207d75e27cae..1592e0e945cbd6a9b1828223ac7f76525a6957fa 100644 (file)
@@ -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;
         }