* Runs the application. * * @returns The application's exit code. */
| 995 | * @returns The application's exit code. |
| 996 | */ |
| 997 | int Application::Run() |
| 998 | { |
| 999 | #ifndef _WIN32 |
| 1000 | struct sigaction sa; |
| 1001 | memset(&sa, 0, sizeof(sa)); |
| 1002 | sa.sa_handler = &Application::SigUsr1Handler; |
| 1003 | sa.sa_flags = SA_RESTART; |
| 1004 | sigaction(SIGUSR1, &sa, nullptr); |
| 1005 | #else /* _WIN32 */ |
| 1006 | SetConsoleCtrlHandler(&Application::CtrlHandler, TRUE); |
| 1007 | #endif /* _WIN32 */ |
| 1008 | |
| 1009 | #ifdef _WIN32 |
| 1010 | try { |
| 1011 | UpdatePidFile(Configuration::PidPath); |
| 1012 | } catch (const std::exception&) { |
| 1013 | Log(LogCritical, "Application") |
| 1014 | << "Cannot update PID file '" << Configuration::PidPath << "'. Aborting."; |
| 1015 | return EXIT_FAILURE; |
| 1016 | } |
| 1017 | #endif /* _WIN32 */ |
| 1018 | |
| 1019 | SetStartTime(Utility::GetTime()); |
| 1020 | |
| 1021 | return Main(); |
| 1022 | } |
| 1023 | |
| 1024 | void Application::UpdatePidFile(const String& filename) |
| 1025 | { |
no test coverage detected