Skip to content

Commit f1eb6e5

Browse files
author
yawzhang
committed
[TEST] generate coredump file when crash happend
1 parent 7db06b1 commit f1eb6e5

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/logging/stacktrace.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,17 @@ static void exit_with_default_sighandler(const SignalType fatal_signal_id) {
8181
<< std::flush;
8282
}
8383

84-
//::kill(::getpid(), fatal_signal_id);
85-
if (fatal_signal_id == SIGABRT) {
86-
std::_Exit(fatal_signal_id);
87-
} else {
88-
std::exit(fatal_signal_id);
84+
// Use std::raise to send the signal to the current process
85+
if (std::raise(fatal_signal_id) != 0) {
86+
std::cerr << "\n"
87+
<< __FUNCTION__ << ":" << __LINE__
88+
<< ". Failed to raise signal, trying kill() "
89+
<< fatal_signal_id << " \n\n"
90+
<< std::flush;
8991
}
92+
93+
// Fallback in case std::raise doesn't terminate the process
94+
::kill(::getpid(), fatal_signal_id);
9095
}
9196

9297
/** \return signal_name Ref: signum.hpp and \ref installSignalHandler

0 commit comments

Comments
 (0)