+ (void) task_terminate(task);
+
+out:
+ if ((exception != EXC_CRASH) && (exception != EXC_RESOURCE))
+ thread_exception_return();
+ return;
+}
+
+kern_return_t
+bsd_exception(
+ exception_type_t exception,
+ mach_exception_data_t code,
+ mach_msg_type_number_t codeCnt)
+{
+ task_t task;
+ struct exception_action *excp;
+ lck_mtx_t *mutex;
+ thread_t self = current_thread();
+ kern_return_t kr;
+
+ /*
+ * Maybe the task level will handle it.
+ */
+ task = current_task();
+ mutex = &task->lock;
+ excp = &task->exc_actions[exception];
+
+ kr = exception_deliver(self, exception, code, codeCnt, excp, mutex);
+
+ if (kr == KERN_SUCCESS || kr == MACH_RCV_PORT_DIED)
+ return(KERN_SUCCESS);
+ return(KERN_FAILURE);
+}
+
+
+/*
+ * Raise an exception on a task.
+ * This should tell launchd to launch Crash Reporter for this task.
+ */
+kern_return_t task_exception_notify(exception_type_t exception,
+ 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(exception, 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);