objective-cmacoscocoamacos-carboncrash-reports

Mac OS X: prevent the crash report window from appearing in my app


I'm developing an app on Mac OS X which is suspected to crash sometimes (well, not due to my app, but due to unstable third-party plug-ins it loads. This app actually acts as a crash firewall; many crashes can happen at startup, so no need to bug the user about it at this time).

Is there a way to prevent the crash report window from popping in front of the user?

Thanks!

PS: this is about this window, but not for WebKit: A crash reporting window on Mac OS X


Solution

  • I'm not aware of any really supported solution, but there are some (ugly) ways to achieve it.

    First, you need to catch the signal yourself. I assume you know how to do that (see sigaction). Then within your crash signal handler, call _exit(). That's with a leading underscore. It's a faster, less safe version of exit(). This will typically avoid the crash reporter. I've used this in some C++ projects that had such flakey memory management that they often crashed on shutdown. I'm not proud of it; I'm just saying it works....

    The other solution is to launch another second process during your crash handler. The second process waits around for CrashReporter to launch. When it does, kill it. The last time I tested this approach was 10.5. I don't know if 10.7 still launches the same kind of process to display that alert.