Revert changes in daemonize.c from commit 22d6f39e7fb270d0c011bae820d2f8adc8b19061
authorMartin C Drohmann <martin@connectedsignals.com>
Wed, 1 Jun 2016 19:12:44 +0000 (12:12 -0700)
committerAndy Green <andy@warmcat.com>
Thu, 2 Jun 2016 05:06:32 +0000 (13:06 +0800)
lib/daemonize.c

index e916294..73b2d58 100644 (file)
@@ -142,9 +142,20 @@ lws_daemonize(const char *_lock_path)
                exit(9);
        }
 
-       /* If we got a good PID, then we can exit the parent process. */
-       if (pid_daemon > 0)
-               exit(0);
+        /* If we got a good PID, then we can exit the parent process. */
+       if (pid_daemon > 0) {
+
+               /*
+                * Wait for confirmation signal from the child via
+                * SIGCHILD / USR1, or for two seconds to elapse
+                * (SIGALRM).  pause() should not return.
+                */
+               alarm(2);
+
+               pause();
+               /* should not be reachable */
+               exit(1);
+       }
 
        /* At this point we are executing as the child process */
        parent = getppid();