diff options
author | Sadie Powell <sadie@witchery.services> | 2024-01-05 11:55:20 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2024-01-05 12:00:28 +0000 |
commit | 4573e1925dc62415306a29e7fbbec6727649aef9 (patch) | |
tree | 4ff4ae30a3408cf6507d7b7d1271b54836cf40f6 | |
parent | a40f8e0b9d397f2e15d141c5bec823c633a6f90a (diff) |
Use normal exit codes when exiting the process.
-rw-r--r-- | include/anope.h | 2 | ||||
-rw-r--r-- | include/version.cpp | 10 | ||||
-rw-r--r-- | src/init.cpp | 11 | ||||
-rw-r--r-- | src/main.cpp | 5 |
4 files changed, 16 insertions, 12 deletions
diff --git a/include/anope.h b/include/anope.h index 4b1e55bd5..96ded65a2 100644 --- a/include/anope.h +++ b/include/anope.h @@ -416,7 +416,7 @@ namespace Anope * initializing language support, loading modules, and loading databases. * @throws CoreException if something bad went wrong */ - extern void Init(int ac, char **av); + extern bool Init(int ac, char **av); /** Calls the save database event */ diff --git a/include/version.cpp b/include/version.cpp index 8dd24eaf3..a33d42881 100644 --- a/include/version.cpp +++ b/include/version.cpp @@ -172,19 +172,19 @@ int main(int argc, char *argv[]) std::map<std::string, std::string> versions, old_versions; if (!read_version_sh(version_sh, versions)) - return -1; + return EXIT_FAILURE; std::string git_version = get_git_hash(git_dir); if (!write_build_h(buildh, git_version)) - return -1; + return EXIT_FAILURE; read_version_h(versionh, old_versions); if (versions == old_versions) - return 0; + return EXIT_SUCCESS; if (!write_version_h(versionh, versions)) - return -1; + return EXIT_FAILURE; - return 0; + return EXIT_SUCCESS; } diff --git a/src/init.cpp b/src/init.cpp index 961771c15..0e14876d2 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -285,7 +285,7 @@ static void setuidgid() #endif } -void Anope::Init(int ac, char **av) +bool Anope::Init(int ac, char **av) { /* Set file creation mask and group ID. */ #if defined(DEFUMASK) && HAVE_UMASK @@ -300,7 +300,8 @@ void Anope::Init(int ac, char **av) if (GetCommandLineArgument("version", 'v')) { Log(LOG_TERMINAL) << "Anope-" << Anope::Version() << " -- " << Anope::VersionBuildString(); - throw CoreException(); + Anope::ReturnValue = EXIT_SUCCESS; + return false; } if (GetCommandLineArgument("help", 'h')) @@ -326,7 +327,8 @@ void Anope::Init(int ac, char **av) Log(LOG_TERMINAL) << ""; Log(LOG_TERMINAL) << "Further support is available from https://www.anope.org/"; Log(LOG_TERMINAL) << "Or visit us on IRC at irc.anope.org #anope"; - throw CoreException(); + Anope::ReturnValue = EXIT_SUCCESS; + return false; } if (GetCommandLineArgument("nofork", 'n')) @@ -449,7 +451,7 @@ void Anope::Init(int ac, char **av) sigemptyset(&mask); sigsuspend(&mask); - exit(Anope::ReturnValue); + return false; } else if (i == -1) { @@ -560,4 +562,5 @@ void Anope::Init(int ac, char **av) ci->Sync(); Serialize::CheckTypes(); + return true; } diff --git a/src/main.cpp b/src/main.cpp index 5543ceebe..f2228eead 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -137,12 +137,13 @@ int main(int ac, char **av, char **envp) try { /* General initialization first */ - Anope::Init(ac, av); + if (!Anope::Init(ac, av)) + return Anope::ReturnValue; } catch (const CoreException &ex) { Log() << ex.GetReason(); - return -1; + return EXIT_FAILURE; } try |