-void InspIRCd::SetSignals()
-{
-#ifndef _WIN32
- signal(SIGALRM, SIG_IGN);
- signal(SIGCHLD, SIG_IGN);
- signal(SIGHUP, InspIRCd::SetSignal);
- signal(SIGPIPE, SIG_IGN);
- signal(SIGUSR1, SIG_IGN);
- signal(SIGUSR2, SIG_IGN);
- signal(SIGXFSZ, SIG_IGN);
-#endif
- signal(SIGTERM, InspIRCd::SetSignal);
-}
-
-bool InspIRCd::DaemonSeed()
-{
-#ifdef _WIN32
- std::cout << "InspIRCd Process ID: " << con_green << GetCurrentProcessId() << con_reset << std::endl;
- return true;
-#else
- // Do not use exit() here: It will exit with status SIGTERM which would break e.g. daemon scripts
- signal(SIGTERM, VoidSignalHandler);
-
- int childpid = fork();
- if (childpid < 0)
- return false;
- else if (childpid > 0)
- {
- /* We wait here for the child process to kill us,
- * so that the shell prompt doesnt come back over
- * 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(EXIT_STATUS_NOERROR);
- }
- setsid ();
- std::cout << "InspIRCd Process ID: " << con_green << getpid() << con_reset << std::endl;
-
- signal(SIGTERM, InspIRCd::SetSignal);
-
- rlimit rl;
- if (getrlimit(RLIMIT_CORE, &rl) == -1)
- {
- this->Logs->Log("STARTUP", LOG_DEFAULT, "Failed to getrlimit()!");
- return false;
- }
- rl.rlim_cur = rl.rlim_max;
-
- if (setrlimit(RLIMIT_CORE, &rl) == -1)
- this->Logs->Log("STARTUP", LOG_DEFAULT, "setrlimit() failed, cannot increase coredump size.");
-
- return true;
-#endif
-}
-