| 989 | |
| 990 | |
| 991 | void BaseDaemon::initializeTerminationAndSignalProcessing() |
| 992 | { |
| 993 | SentryWriter::initialize(config()); |
| 994 | std::set_terminate(terminate_handler); |
| 995 | |
| 996 | /// We want to avoid SIGPIPE when working with sockets and pipes, and just handle return value/errno instead. |
| 997 | blockSignals({SIGPIPE}); |
| 998 | |
| 999 | /// Setup signal handlers. |
| 1000 | /// SIGTSTP is added for debugging purposes. To output a stack trace of any running thread at anytime. |
| 1001 | |
| 1002 | addSignalHandler({SIGABRT, SIGSEGV, SIGILL, SIGBUS, SIGSYS, SIGFPE, SIGPIPE, SIGTSTP, SIGTRAP}, signalHandler, &handled_signals); |
| 1003 | addSignalHandler({SIGHUP, SIGUSR1}, closeLogsSignalHandler, &handled_signals); |
| 1004 | addSignalHandler({SIGINT, SIGQUIT, SIGTERM}, terminateRequestedSignalHandler, &handled_signals); |
| 1005 | addSignalHandler({SIGUSR2}, minidumpSignalHandler, &handled_signals); |
| 1006 | |
| 1007 | #if defined(SANITIZER) |
| 1008 | __sanitizer_set_death_callback(sanitizerDeathCallback); |
| 1009 | #endif |
| 1010 | |
| 1011 | /// Set up Poco ErrorHandler for Poco Threads. |
| 1012 | static KillingErrorHandler killing_error_handler; |
| 1013 | Poco::ErrorHandler::set(&killing_error_handler); |
| 1014 | |
| 1015 | signal_pipe.setNonBlockingWrite(); |
| 1016 | signal_pipe.tryIncreaseSize(1 << 20); |
| 1017 | |
| 1018 | signal_listener = std::make_unique<SignalListener>(*this); |
| 1019 | signal_listener_thread.start(*signal_listener); |
| 1020 | |
| 1021 | #if defined(__ELF__) && !defined(__FreeBSD__) |
| 1022 | String build_id_hex = DB::SymbolIndex::instance()->getBuildIDHex(); |
| 1023 | if (build_id_hex.empty()) |
| 1024 | build_id_info = "no build id"; |
| 1025 | else |
| 1026 | build_id_info = "build id: " + build_id_hex; |
| 1027 | #else |
| 1028 | build_id_info = "no build id"; |
| 1029 | #endif |
| 1030 | |
| 1031 | #if defined(__linux__) |
| 1032 | std::string executable_path = getExecutablePath(); |
| 1033 | |
| 1034 | if (!executable_path.empty()) |
| 1035 | stored_binary_hash = DB::Elf(executable_path).getBinaryHash(); |
| 1036 | #endif |
| 1037 | } |
| 1038 | |
| 1039 | void BaseDaemon::logRevision() const |
| 1040 | { |
nothing calls this directly
no test coverage detected