diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-18 16:42:06 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-18 16:42:06 +0000 |
commit | 521493c0f1675b7ee408aa2dd846f49ba1a3f4e2 (patch) | |
tree | 2bc286c12d30580954a993d5bf7aed512123bffc /src | |
parent | f3e30a97d234c8f2fbca461bd3801febc6cf2148 (diff) |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/inspircd.cpp | 22 |
1 files 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); |