On Sep 22, 2009, at 2:27 PM, Alastair Houghton wrote:

If you was *your* process that crashed, on "normal" UNIX-like systems you can use signal handlers to catch the crash and do something about it. Likewise, on a normal UNIX-like platform you'd get a SIGCHLD from the system and you could check the process exit status. Or you could act as a debugger using the ptrace() API.

On OS X though, you can't (or couldn't, last I checked which was some time ago) intercept the system crash reporter using signal- related APIs because it's triggered by the lower-level Mach exception port. Even if you somehow handle the signal (in the parent or the child process), the crash reporter is still triggered via the Mach exception port.

On Tiger and earlier, the CrashReporter would generate a crash report for a Mach exception even if it was later delivered as a signal and handled by the process. Since Leopard, though, a crash report is only generated if the signal is not handled. So, handling signals is sufficient to suppress crash reports these days.

That said, it's actually pretty simple to disconnect the CrashReporter from your process using Mach routines. I had to do this for Wine on Tiger because Wine routinely provokes exceptions (and uses signal handlers to deal with the consequences) and the CrashReporter was suspending the process while it generated its report, slowing it _way_ down.

        kern_return_t kret = task_set_exception_ports(
            mach_task_self(),
EXC_MASK_BAD_ACCESS | EXC_MASK_BAD_INSTRUCTION | EXC_MASK_ARITHMETIC,
            MACH_PORT_NULL,
            EXCEPTION_STATE_IDENTITY,
            MACHINE_THREAD_STATE);

I went into it in more depth here: 
http://lists.apple.com/archives/unix-porting/2007/Mar/msg00009.html

Regards,
Ken

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to