From f3e30a97d234c8f2fbca461bd3801febc6cf2148 Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 18 Aug 2006 16:32:31 +0000 Subject: [PATCH] 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 --- src/inspircd.cpp | 16 ++++++++++------ 1 file 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"); -- 2.39.5