summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-18 16:32:31 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-18 16:32:31 +0000
commitf3e30a97d234c8f2fbca461bd3801febc6cf2148 (patch)
tree925fc585e2d0f225822a7edd6baf59dc665c0375 /src
parent05066cfa55a487407ea897cad548207f5ac31539 (diff)
When daemonizing, have parent process wait forever, and child process kill it when we're done initializing
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4953 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/inspircd.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 3fddb2d8b..9ebb92b1e 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -120,9 +120,11 @@ bool InspIRCd::DaemonSeed()
return (ERROR);
else if (childpid > 0)
{
- /* We wait a few seconds here, so that the shell prompt doesnt come back over the output */
- sleep(6);
- exit (0);
+ /* 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);
}
setsid ();
umask (007);
@@ -140,7 +142,7 @@ bool InspIRCd::DaemonSeed()
if (setrlimit(RLIMIT_CORE, &rl) == -1)
this->Log(DEFAULT,"setrlimit() failed, cannot increase coredump size.");
}
-
+
return true;
}
@@ -303,9 +305,11 @@ InspIRCd::InspIRCd(int argc, char** argv)
if (!Config->nofork)
{
- fclose(stdout);
- fclose(stderr);
+ if (kill(getppid(), SIGTERM) == -1)
+ printf("Error killing parent process: %s\n",strerror(errno));
fclose(stdin);
+ fclose(stderr);
+ fclose(stdout);
}
printf("\nInspIRCd is now running!\n");