Commit de75983a authored by Fumitoshi Ukai's avatar Fumitoshi Ukai

Merge pull request #74 from yoshisatoyanagisawa/fix_sigabrt_action

Reset SIGABRT action only if FailureSignalHandler is installed.
parents f46e0745 cda16b34
......@@ -923,6 +923,9 @@ template <bool>
struct CompileAssert {
};
struct CrashReason;
// Returns true if FailureSignalHandler is installed.
bool IsFailureSignalHandlerInstalled();
} // namespace glog_internal_namespace_
#define GOOGLE_GLOG_COMPILE_ASSERT(expr, msg) \
......
......@@ -335,6 +335,22 @@ void FailureSignalHandler(int signal_number,
#endif // HAVE_SIGACTION
namespace glog_internal_namespace_ {
bool IsFailureSignalHandlerInstalled() {
#ifdef HAVE_SIGACTION
struct sigaction sig_action;
memset(&sig_action, 0, sizeof(sig_action));
sigemptyset(&sig_action.sa_mask);
sigaction(SIGABRT, NULL, &sig_action);
if (sig_action.sa_sigaction == &FailureSignalHandler)
return true;
#endif // HAVE_SIGACTION
return false;
}
} // namespace glog_internal_namespace_
void InstallFailureSignalHandler() {
#ifdef HAVE_SIGACTION
// Build the sigaction struct.
......
......@@ -138,13 +138,15 @@ static void DumpStackTraceAndExit() {
// TOOD(hamaji): Use signal instead of sigaction?
#ifdef HAVE_SIGACTION
if (IsFailureSignalHandlerInstalled()) {
// Set the default signal handler for SIGABRT, to avoid invoking our
// own signal handler installed by InstallFailedSignalHandler().
// own signal handler installed by InstallFailureSignalHandler().
struct sigaction sig_action;
memset(&sig_action, 0, sizeof(sig_action));
sigemptyset(&sig_action.sa_mask);
sig_action.sa_handler = SIG_DFL;
sigaction(SIGABRT, &sig_action, NULL);
}
#endif // HAVE_SIGACTION
abort();
......
......@@ -910,6 +910,9 @@ template <bool>
struct CompileAssert {
};
struct CrashReason;
// Returns true if FailureSignalHandler is installed.
bool IsFailureSignalHandlerInstalled();
} // namespace glog_internal_namespace_
#define GOOGLE_GLOG_COMPILE_ASSERT(expr, msg) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment