File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -130,13 +130,15 @@ void dfhack_crashlog_thread() {
130130 std::quick_exit (1 );
131131}
132132
133+ std::terminate_handler term_handler = nullptr ;
134+
133135const int desired_signals[3 ] = {SIGSEGV,SIGILL,SIGABRT};
134136namespace DFHack {
135137 void dfhack_crashlog_init () {
136138 for (int signal : desired_signals) {
137139 std::signal (signal, dfhack_crashlog_handle_signal);
138140 }
139- std::set_terminate (dfhack_crashlog_handle_terminate);
141+ term_handler = std::set_terminate (dfhack_crashlog_handle_terminate);
140142
141143 // https://sourceware.org/glibc/manual/latest/html_mono/libc.html#index-backtrace-1
142144 // backtrace is AsyncSignal-Unsafe due to dynamic loading of libgcc_s
@@ -147,6 +149,11 @@ namespace DFHack {
147149 }
148150
149151 void dfhack_crashlog_shutdown () {
152+ for (int signal : desired_signals) {
153+ std::signal (signal, SIG_DFL);
154+ }
155+ std::set_terminate (term_handler);
156+
150157 shutdown = true ;
151158 flag_set (crashlog_ready);
152159 crashlog_thread.join ();
You can’t perform that action at this time.
0 commit comments