From: brain Date: Fri, 18 Aug 2006 16:42:06 +0000 (+0000) Subject: Checking if child pid still exists, if it vanishes we exit X-Git-Tag: v2.0.23~7361 X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=521493c0f1675b7ee408aa2dd846f49ba1a3f4e2;p=user%2Fhenk%2Fcode%2Finspircd.git Checking if child pid still exists, if it vanishes we exit git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4954 e03df62e-2008-0410-955e-edbf42e46eb7 --- diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 9ebb92b1e..e8e93bcc5 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -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);