From d682f3f2c962d4f6f986ade58cf3c1dc4adfbc67 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sat, 23 Apr 2022 09:46:28 +0100 Subject: Only write to the pid file on boot. Being able to change this after first boot is error prone and does not work well on system-wide installs where the server needs root to write the file. Closes #566. --- src/inspircd.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/inspircd.cpp') diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 9ea707d97..943de329b 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -418,7 +418,7 @@ void InspIRCd::Cleanup() Logs.CloseLogs(); } -void InspIRCd::WritePID(bool exitonfail) +void InspIRCd::WritePID() { #ifndef _WIN32 if (!ServerInstance->Config->cmdline.writepid) @@ -436,11 +436,9 @@ void InspIRCd::WritePID(bool exitonfail) } else { - if (exitonfail) - std::cout << "Failed to write PID-file '" << pidfile << "', exiting." << std::endl; - this->Logs.Log("STARTUP", LOG_DEFAULT, "Failed to write PID-file '%s'%s", pidfile.c_str(), (exitonfail ? ", exiting." : "")); - if (exitonfail) - Exit(EXIT_STATUS_PID); + std::cout << "Failed to write PID-file '" << pidfile << "', exiting." << std::endl; + this->Logs.Log("STARTUP", LOG_DEFAULT, "Failed to write PID-file '%s', exiting.", pidfile.c_str()); + Exit(EXIT_STATUS_PID); } #endif } @@ -586,7 +584,7 @@ InspIRCd::InspIRCd(int argc, char** argv) QueryPerformanceFrequency(&stats.QPFrequency); #endif - WritePID(true); + WritePID(); DropRoot(); Logs.Log("STARTUP", LOG_DEFAULT, "Startup complete as '%s'[%s], %lu max open sockets", Config->ServerName.c_str(),Config->GetSID().c_str(), SocketEngine::GetMaxFds()); -- cgit v1.3.1-10-gc9f91