From 9c3d9076aaf75da68f189b9d1dd33905c6fe205a Mon Sep 17 00:00:00 2001 From: sowle Date: Thu, 19 Sep 2019 16:57:16 +0300 Subject: [PATCH] daemon: terminal handler implemented (may be helpful in a fighting with mysterious crashes) --- src/daemon/daemon.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index e2e40876..9e5953be 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -87,6 +87,13 @@ struct core_critical_error_handler_t : public currency::i_critical_error_handler bool dont_stop_on_low_space; }; +void terminate_handler_func() +{ + LOG_ERROR("\n\nTERMINATE HANDLER\n"); // should print callstack + std::fflush(nullptr); // all open output streams are flushed + std::abort(); // default terminate handler's behavior +} + int main(int argc, char* argv[]) { try @@ -112,6 +119,8 @@ int main(int argc, char* argv[]) // setup custom callstack retrieving function epee::misc_utils::get_callstack(tools::get_callstack); + std::set_terminate(&terminate_handler_func); + po::options_description desc_cmd_only("Command line options"); po::options_description desc_cmd_sett("Command line options and settings options", 130, 83);