summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/mac/os_crash_dumps.cc16
1 files changed, 14 insertions, 2 deletions
diff --git a/base/mac/os_crash_dumps.cc b/base/mac/os_crash_dumps.cc
index e82fd73..e6b0996 100644
--- a/base/mac/os_crash_dumps.cc
+++ b/base/mac/os_crash_dumps.cc
@@ -8,6 +8,7 @@
#include <unistd.h>
#include "base/basictypes.h"
+#include "base/logging.h"
namespace base {
namespace mac {
@@ -37,8 +38,19 @@ void DisableOSCrashDumps() {
};
// For all these signals, just wire things up so we exit immediately.
- for (size_t i = 0; i < arraysize(signals_to_intercept); ++i)
- signal(signals_to_intercept[i], ExitSignalHandler);
+ for (size_t i = 0; i < arraysize(signals_to_intercept); ++i) {
+ struct sigaction act = {};
+ act.sa_handler = ExitSignalHandler;
+
+ // It is better to allow the signal handler to run on the stack
+ // registered with sigaltstack(), if one is present.
+ act.sa_flags = SA_ONSTACK;
+
+ if (sigemptyset(&act.sa_mask) != 0)
+ DLOG_ERRNO(FATAL) << "sigemptyset() failed";
+ if (sigaction(signals_to_intercept[i], &act, NULL) != 0)
+ DLOG_ERRNO(FATAL) << "sigaction() failed";
+ }
}
} // namespace mac