From 9cd7a2e54683a05d175a86e901f2f0df7d680902 Mon Sep 17 00:00:00 2001 From: Chris Novakovic Date: Mon, 4 Jun 2018 12:40:32 +0100 Subject: Add --nopid command line option (#1497). Add a --nopid command line option, which causes a PID file not to be written to the file system regardless of the presence of the tag in the configuration file or the value of its "file" variable if it is present.--- src/inspircd.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/inspircd.cpp b/src/inspircd.cpp index a671c3d7b..ab5a9e191 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -186,6 +186,12 @@ bool InspIRCd::DaemonSeed() void InspIRCd::WritePID(const std::string& filename, bool exitonfail) { #ifndef _WIN32 + if (!ServerInstance->Config->cmdline.writepid) + { + this->Logs->Log("STARTUP", LOG_DEFAULT, "--nopid specified on command line; PID file not written."); + return; + } + std::string fname(filename); if (fname.empty()) fname = ServerInstance->Config->Paths.PrependData("inspircd.pid"); @@ -225,7 +231,7 @@ InspIRCd::InspIRCd(int argc, char** argv) : FailedPortList pl; // Flag variables passed to getopt_long() later int do_version = 0, do_nofork = 0, do_debug = 0, - do_nolog = 0, do_root = 0; + do_nolog = 0, do_nopid = 0, do_root = 0; // Initialize so that if we exit before proper initialization they're not deleted this->Config = 0; @@ -271,6 +277,7 @@ InspIRCd::InspIRCd(int argc, char** argv) : { "config", required_argument, NULL, 'c' }, { "debug", no_argument, &do_debug, 1 }, { "nolog", no_argument, &do_nolog, 1 }, + { "nopid", no_argument, &do_nopid, 1 }, { "runasroot", no_argument, &do_root, 1 }, { "version", no_argument, &do_version, 1 }, #ifdef INSPIRCD_ENABLE_TESTSUITE @@ -297,7 +304,7 @@ InspIRCd::InspIRCd(int argc, char** argv) : default: /* Fall through to handle other weird values too */ std::cout << "Unknown parameter '" << argv[optind-1] << "'" << std::endl; - std::cout << "Usage: " << argv[0] << " [--nofork] [--nolog] [--debug] [--config ]" << std::endl << + std::cout << "Usage: " << argv[0] << " [--nofork] [--nolog] [--nopid] [--debug] [--config ]" << std::endl << std::string(static_cast(8+strlen(argv[0])), ' ') << "[--runasroot] [--version]" << std::endl; Exit(EXIT_STATUS_ARGV); break; @@ -325,6 +332,7 @@ InspIRCd::InspIRCd(int argc, char** argv) : Config->cmdline.nofork = (do_nofork != 0); Config->cmdline.forcedebug = (do_debug != 0); Config->cmdline.writelog = !do_nolog; + Config->cmdline.writepid = !do_nopid; if (do_debug) { -- cgit v1.3.1-10-gc9f91