diff --git a/lib/cli/daemoncommand.cpp b/lib/cli/daemoncommand.cpp index dc6cab2bd..2eaefaeda 100644 --- a/lib/cli/daemoncommand.cpp +++ b/lib/cli/daemoncommand.cpp @@ -191,6 +191,20 @@ pid_t l_UmbrellaPid = 0; static Atomic l_AllowedToWork (false); #endif /* _WIN32 */ +void throw_test_exception() { + if (!Utility::GetFromEnvironment("DEBUG_ABORT").IsEmpty()) { + abort(); + } + if (!Utility::GetFromEnvironment("DEBUG_THROW_CXX").IsEmpty()) { + throw std::runtime_error("test exception"); + } +#ifdef _WIN32 + if (!Utility::GetFromEnvironment("DEBUG_THROW_SEH").IsEmpty()) { + RaiseException(42, 0, 0, nullptr); + } +#endif +} + /** * Do the actual work (config loading, ...) * @@ -254,6 +268,8 @@ int RunWorker(const std::vector& configs, bool closeConsoleLog = fa } } + throw_test_exception(); + /* Create the internal API object storage. Do this here too with setups without API. */ ConfigObjectUtility::CreateStorage(); @@ -483,6 +499,7 @@ static pid_t StartUnixWorker(const std::vector& configs, bool close Log(LogCritical, "cli") << "Exception in main process: " << DiagnosticInformation(ex); _exit(EXIT_FAILURE); } catch (...) { + throw; _exit(EXIT_FAILURE); } @@ -648,8 +665,10 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector