]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Checking if child pid still exists, if it vanishes we exit
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 18 Aug 2006 16:42:06 +0000 (16:42 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 18 Aug 2006 16:42:06 +0000 (16:42 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4954 e03df62e-2008-0410-955e-edbf42e46eb7

src/inspircd.cpp

index 9ebb92b1ef1d4c65658cae547fb386c516ac703e..e8e93bcc52fbe169e4e79cbb0fa498f828acc356 100644 (file)
@@ -107,10 +107,11 @@ void InspIRCd::Rehash(int status)
 
 void InspIRCd::SetSignals(bool SEGVHandler)
 {
-       signal (SIGALRM, SIG_IGN);
-       signal (SIGHUP, InspIRCd::Rehash);
-       signal (SIGPIPE, SIG_IGN);
-       signal (SIGTERM, InspIRCd::Exit);
+       signal(SIGALRM, SIG_IGN);
+       signal(SIGHUP, InspIRCd::Rehash);
+       signal(SIGPIPE, SIG_IGN);
+       signal(SIGTERM, InspIRCd::Exit);
+       signal(SIGCHLD, SIG_IGN);
 }
 
 bool InspIRCd::DaemonSeed()
@@ -122,9 +123,16 @@ bool InspIRCd::DaemonSeed()
        {
                /* We wait here for the child process to kill us,
                 * so that the shell prompt doesnt come back over
-                * the output */
-               while (1)
-                       sleep(600);
+                * the output.
+                * Sending a kill with a signal of 0 just checks
+                * if the child pid is still around. If theyre not,
+                * they threw an error and we should give up.
+                */
+               while (kill(childpid, 0) != -1)
+               {
+                       sleep(1);
+               }
+               exit(ERROR);
        }
        setsid ();
        umask (007);