모든 마하 스레드 및/또는 작업 (맨 위에는 BSD 계층 프로세스가 구현되는 기본 커널 객체)에는 예외 포트가 있습니다. 스레드, 작업 및 호스트라는 세 가지 포트 수준을 사용할 수 있습니다. 예외가 발생하면 마하 메시지가 보내집니다 - 먼저 스레드 포트로, 그 다음 아무도 잡히지 않으면 - 작업이 있고 마지막으로 호스트가됩니다. 포트를 얻으면 예외를 잡거나 디버깅하거나 (OS X에서 gdb처럼) 크래시 덤프를 생성 할 수 있습니다 (Crash Reporter처럼). 특히, launchd에 - 모든 OS X의 시스템 작업의 부모 - 자신의 예외 포트를 등록, 그래서 메시지를 가져온 다음 CrashReporter (당신은 launchd에의 ReportCrash의 PLIST에서 볼 수 트리거 :
<key>MachServices</key>
<dict>
<key>com.apple.ReportCrash.DirectoryService</key>
<dict>
<key>DrainMessagesOnCrash</key>
<string>All</string>
<key>ExceptionServer</key>
<dict/>
</dict>
</dict>
XNU 커널 코드는 EXC_CRASH에서 메시지를 전송할 수 있습니다. 특히, proc_prepareexit는 다음을 수행합니다.
/* If a core should be generated, notify crash reporter */
if (hassigprop(WTERMSIG(rv), SA_CORE) || ((p->p_csflags & CS_KILLED) != 0)) {
/*
* Workaround for processes checking up on PT_DENY_ATTACH:
* should be backed out post-Leopard (details in 5431025).
*/
if ((SIGSEGV == WTERMSIG(rv)) &&
(p->p_pptr->p_lflag & P_LNOATTACH)) {
goto skipcheck;
}
/*
* Crash Reporter looks for the signal value, original exception
* type, and low 20 bits of the original code in code[0]
* (8, 4, and 20 bits respectively). code[1] is unmodified.
*/
code = ((WTERMSIG(rv) & 0xff) << 24) |
((ut->uu_exception & 0x0f) << 20) |
((int)ut->uu_code & 0xfffff);
subcode = ut->uu_subcode;
(void) task_exception_notify(EXC_CRASH, code, subcode); // <-- Sends the msg
}