MCPcopy Create free account
hub / github.com/ByConity/ByConity / initializeTerminationAndSignalProcessing

Method initializeTerminationAndSignalProcessing

base/daemon/BaseDaemon.cpp:991–1037  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

989
990
991void 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
1039void BaseDaemon::logRevision() const
1040{

Callers

nothing calls this directly

Calls 12

blockSignalsFunction · 0.85
addSignalHandlerFunction · 0.85
getExecutablePathFunction · 0.85
setNonBlockingWriteMethod · 0.80
tryIncreaseSizeMethod · 0.80
getBuildIDHexMethod · 0.80
getBinaryHashMethod · 0.80
configFunction · 0.50
setFunction · 0.50
ElfClass · 0.50
startMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected