From 0a6adff4e0e0f449afabe704ecb7358bd1a29f15 Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 7 Apr 2007 16:12:12 +0000 Subject: Set the signals to 'quick exit' before the fork, not straight after, because theres a very slight chance of minor race condition if the child process sends kill() before we signal() otherwise. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6758 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/inspircd.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 0fe6fdec2..268dfece0 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -209,6 +209,8 @@ void InspIRCd::QuickExit(int status) bool InspIRCd::DaemonSeed() { + signal(SIGTERM, InspIRCd::QuickExit); + int childpid; if ((childpid = fork ()) < 0) return false; @@ -221,7 +223,6 @@ bool InspIRCd::DaemonSeed() * if the child pid is still around. If theyre not, * they threw an error and we should give up. */ - signal(SIGTERM, InspIRCd::QuickExit); while (kill(childpid, 0) != -1) sleep(1); exit(0); @@ -230,6 +231,8 @@ bool InspIRCd::DaemonSeed() umask (007); printf("InspIRCd Process ID: \033[1;32m%lu\033[0m\n",(unsigned long)getpid()); + signal(SIGTERM, InspIRCd::Exit); + rlimit rl; if (getrlimit(RLIMIT_CORE, &rl) == -1) { -- cgit v1.2.3