diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-04-07 16:12:12 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-04-07 16:12:12 +0000 |
commit | 0a6adff4e0e0f449afabe704ecb7358bd1a29f15 (patch) | |
tree | 4dfd694ada38480fdb04055d1569d94402bf2b9e /src | |
parent | 45d76881d8b153cb42c28fe61951aa9b6a055cb6 (diff) |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/inspircd.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
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) { |