summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2019-12-08 21:23:22 +0000
committerPeter Powell <petpow@saberuk.com>2019-12-08 21:30:55 +0000
commit9ad873886e518bf3621a88e8c48607ab79020c0a (patch)
treedf648e82dbb5ba4cdec7375b20a93bceaf6bc4b1
parent3faa9e329907bca551843119b27dd84d67eb0f40 (diff)
Convert InspIRCd::SetSignals to a static function.
-rw-r--r--include/inspircd.h4
-rw-r--r--src/inspircd.cpp35
2 files changed, 19 insertions, 20 deletions
diff --git a/include/inspircd.h b/include/inspircd.h
index 97f8b3017..56ad556d7 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -181,10 +181,6 @@ class serverstats
class CoreExport InspIRCd
{
private:
- /** Set up the signal handlers
- */
- void SetSignals();
-
/** The current time, updated in the mainloop
*/
struct timespec TIME;
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 022f06673..6d8272361 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -142,6 +142,7 @@ namespace
// Attempts to fork into the background.
bool ForkIntoBackground()
{
+#ifndef _WIN32
// We use VoidSignalHandler whilst forking to avoid breaking daemon scripts
// if the parent process exits with SIGTERM (15) instead of EXIT_STATUS_NOERROR (0).
signal(SIGTERM, VoidSignalHandler);
@@ -167,8 +168,9 @@ namespace
{
setsid();
signal(SIGTERM, InspIRCd::SetSignal);
- return true;
}
+#endif
+ return true;
}
// Increase the size of a core dump file to improve debugging problems.
@@ -199,6 +201,21 @@ namespace
#endif
}
+ // Sets handlers for various process signals.
+ void 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);
+ }
+
// Required for returning the proper value of EXIT_SUCCESS for the parent process.
void VoidSignalHandler(int)
{
@@ -242,20 +259,6 @@ void InspIRCd::Cleanup()
Logs->CloseLogs();
}
-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);
-}
-
void InspIRCd::WritePID(const std::string& filename, bool exitonfail)
{
#ifndef _WIN32
@@ -450,7 +453,7 @@ InspIRCd::InspIRCd(int argc, char** argv)
}
#endif
- this->SetSignals();
+ SetSignals();
if (!Config->cmdline.nofork && !ForkIntoBackground())
{