1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/mac/os_crash_dumps.h"
10 #include "base/basictypes.h"
17 void ExitSignalHandler(int sig
) {
18 // A call to exit() can call atexit() handlers. If we SIGSEGV due
19 // to a corrupt heap, and if we have an atexit handler that
20 // allocates or frees memory, we are in trouble if we do not _exit.
26 void DisableOSCrashDumps() {
27 // These are the POSIX signals corresponding to the Mach exceptions that
28 // Apple Crash Reporter handles. See ux_exception() in xnu's
29 // bsd/uxkern/ux_exception.c and machine_exception() in xnu's
30 // bsd/dev/*/unix_signal.c.
31 const int signals_to_intercept
[] = {
32 SIGILL
, // EXC_BAD_INSTRUCTION
33 SIGTRAP
, // EXC_BREAKPOINT
34 SIGFPE
, // EXC_ARITHMETIC
35 SIGBUS
, // EXC_BAD_ACCESS
36 SIGSEGV
// EXC_BAD_ACCESS
39 // For all these signals, just wire things up so we exit immediately.
40 for (size_t i
= 0; i
< arraysize(signals_to_intercept
); ++i
)
41 signal(signals_to_intercept
[i
], ExitSignalHandler
);