/* * Raise an EXC_CRASH exception on the dying task. * This should tell launchd to launch Crash Reporter for this task. */ kern_return_t abnormal_exit_notify(mach_exception_data_type_t exccode, mach_exception_data_type_t excsubcode) { mach_exception_data_type_t code[EXCEPTION_CODE_MAX]; wait_interrupt_t wsave; code[0] = exccode; code[1] = excsubcode; wsave = thread_interrupt_level(THREAD_UNINT); exception_triage(EXC_CRASH, code, EXCEPTION_CODE_MAX); (void) thread_interrupt_level(wsave); return (KERN_SUCCESS); }
/* * Handle interface for special performance monitoring * This is a special case of the host exception handler */ kern_return_t sys_perf_notify(thread_t thread, int pid) { host_priv_t hostp; struct exception_action *excp; ipc_port_t xport; wait_interrupt_t wsave; kern_return_t ret; hostp = host_priv_self(); /* Get the host privileged ports */ mach_exception_data_type_t code[EXCEPTION_CODE_MAX]; code[0] = 0xFF000001; /* Set terminate code */ code[1] = pid; /* Pass out the pid */ struct task *task = thread->task; excp = &hostp->exc_actions[EXC_RPC_ALERT]; xport = excp->port; /* Make sure we're not catching our own exception */ if (!IP_VALID(xport) || !ip_active(xport) || task->itk_space == xport->data.receiver) { return(KERN_FAILURE); } wsave = thread_interrupt_level(THREAD_UNINT); ret = exception_deliver( thread, EXC_RPC_ALERT, code, 2, excp, &hostp->lock); (void)thread_interrupt_level(wsave); return(ret); }