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> ...@@ -923,6 +923,9 @@ template <bool>
struct CompileAssert { struct CompileAssert {
}; };
struct CrashReason; struct CrashReason;
// Returns true if FailureSignalHandler is installed.
bool IsFailureSignalHandlerInstalled();
} // namespace glog_internal_namespace_ } // namespace glog_internal_namespace_
#define GOOGLE_GLOG_COMPILE_ASSERT(expr, msg) \ #define GOOGLE_GLOG_COMPILE_ASSERT(expr, msg) \
......
...@@ -335,6 +335,22 @@ void FailureSignalHandler(int signal_number, ...@@ -335,6 +335,22 @@ void FailureSignalHandler(int signal_number,
#endif // HAVE_SIGACTION #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() { void InstallFailureSignalHandler() {
#ifdef HAVE_SIGACTION #ifdef HAVE_SIGACTION
// Build the sigaction struct. // Build the sigaction struct.
......
...@@ -138,13 +138,15 @@ static void DumpStackTraceAndExit() { ...@@ -138,13 +138,15 @@ static void DumpStackTraceAndExit() {
// TOOD(hamaji): Use signal instead of sigaction? // TOOD(hamaji): Use signal instead of sigaction?
#ifdef HAVE_SIGACTION #ifdef HAVE_SIGACTION
// Set the default signal handler for SIGABRT, to avoid invoking our if (IsFailureSignalHandlerInstalled()) {
// own signal handler installed by InstallFailedSignalHandler(). // Set the default signal handler for SIGABRT, to avoid invoking our
struct sigaction sig_action; // own signal handler installed by InstallFailureSignalHandler().
memset(&sig_action, 0, sizeof(sig_action)); struct sigaction sig_action;
sigemptyset(&sig_action.sa_mask); memset(&sig_action, 0, sizeof(sig_action));
sig_action.sa_handler = SIG_DFL; sigemptyset(&sig_action.sa_mask);
sigaction(SIGABRT, &sig_action, NULL); sig_action.sa_handler = SIG_DFL;
sigaction(SIGABRT, &sig_action, NULL);
}
#endif // HAVE_SIGACTION #endif // HAVE_SIGACTION
abort(); abort();
......
...@@ -910,6 +910,9 @@ template <bool> ...@@ -910,6 +910,9 @@ template <bool>
struct CompileAssert { struct CompileAssert {
}; };
struct CrashReason; struct CrashReason;
// Returns true if FailureSignalHandler is installed.
bool IsFailureSignalHandlerInstalled();
} // namespace glog_internal_namespace_ } // namespace glog_internal_namespace_
#define GOOGLE_GLOG_COMPILE_ASSERT(expr, msg) \ #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