From 4399eeaa587e5cb4c4f3b7a6a3a79390e32b7b78 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 20 Mar 2024 21:34:28 +0000 Subject: Add the --nopid option to disable writing a pidfile. This is useful for init scripts that don't fork. --- src/init.cpp | 6 +++++- src/main.cpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/init.cpp b/src/init.cpp index 8bf7d387c..df53ee908 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -221,7 +221,7 @@ static void remove_pidfile() static void write_pidfile() { auto pidfile = Anope::ExpandData(Config->GetBlock("serverinfo")->Get("pid")); - if (pidfile.empty()) + if (Anope::NoPID || pidfile.empty()) return; std::ofstream stream(pidfile.str()); @@ -325,6 +325,7 @@ bool Anope::Init(int ac, char **av) Log(LOG_TERMINAL) << " --modulesdir=modules directory"; Log(LOG_TERMINAL) << "-e, --noexpire"; Log(LOG_TERMINAL) << "-n, --nofork"; + Log(LOG_TERMINAL) << "-p, --nopid"; Log(LOG_TERMINAL) << " --nothird"; Log(LOG_TERMINAL) << " --protocoldebug"; Log(LOG_TERMINAL) << "-r, --readonly"; @@ -352,6 +353,9 @@ bool Anope::Init(int ac, char **av) if (GetCommandLineArgument("nothird")) Anope::NoThird = true; + if (GetCommandLineArgument("nopid", 'p')) + Anope::NoPID = true; + if (GetCommandLineArgument("noexpire", 'e')) Anope::NoExpire = true; diff --git a/src/main.cpp b/src/main.cpp index 7106579c0..498378c43 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -24,7 +24,7 @@ /* Command-line options: */ int Anope::Debug = 0; -bool Anope::ReadOnly = false, Anope::NoFork = false, Anope::NoThird = false, Anope::NoExpire = false, Anope::ProtocolDebug = false; +bool Anope::ReadOnly = false, Anope::NoFork = false, Anope::NoThird = false, Anope::NoPID = false, Anope::NoExpire = false, Anope::ProtocolDebug = false; Anope::string Anope::ServicesDir; Anope::string Anope::ServicesBin; -- cgit