From 521493c0f1675b7ee408aa2dd846f49ba1a3f4e2 Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 18 Aug 2006 16:42:06 +0000 Subject: [PATCH] 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 --- src/inspircd.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) 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); -- 2.39.5