+ /* Re-enable crash reporter */
+ do {
+ kern_return_t kr;
+ mach_port_t bp, ep, mts;
+ thread_state_flavor_t flavor = 0;
+
+#if defined(__ppc__)
+ flavor = PPC_THREAD_STATE64;
+#elif defined(__i386__)
+ flavor = x86_THREAD_STATE;
+#endif
+
+ mts = mach_task_self();
+
+ kr = task_get_bootstrap_port(mts, &bp);
+ if (kr != KERN_SUCCESS) {
+ syslog(LOG_ERR, "task_get_bootstrap_port() failure: %s (%d)",
+ bootstrap_strerror(kr), kr);
+ break;
+ }
+
+ const char* bs = "com.apple.ReportCrash";
+ kr = bootstrap_look_up(bp, (char*)bs, &ep);
+ if (kr != KERN_SUCCESS) {
+ syslog(LOG_ERR, "bootstrap_look_up(%s) failure: %s (%d)",
+ bs, bootstrap_strerror(kr), kr);
+ break;
+ }
+
+ kr = task_set_exception_ports(mts, EXC_MASK_CRASH, ep, EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES, flavor);
+ if (kr != KERN_SUCCESS) {
+ syslog(LOG_ERR, "task_set_exception_ports() failure: %d", kr);
+ break;
+ }
+ } while (0);
+
+ if (fflag && *argv) {
+ char *arg0 = *argv;
+ if (lflag)
+ (void)strlcpy(tbuf, (p = strrchr(*argv, '/')) ?
+ p + 1 : *argv, sizeof(tbuf));
+ else {
+ tbuf[0] = '-';
+ (void)strlcpy(tbuf + 1, (p = strrchr(*argv, '/')) ?
+ p + 1 : *argv, sizeof(tbuf) - 1);
+ }
+ *argv = tbuf;
+ execvp(arg0, argv);
+ err(1, "%s", arg0);
+ } else {
+ if (lflag)
+ (void)strlcpy(tbuf, (p = strrchr(pwd->pw_shell, '/')) ?
+ p + 1 : pwd->pw_shell, sizeof(tbuf));
+ else {
+ tbuf[0] = '-';
+ (void)strlcpy(tbuf + 1, (p = strrchr(pwd->pw_shell, '/')) ?
+ p + 1 : pwd->pw_shell, sizeof(tbuf) - 1);
+ }
+ execlp(pwd->pw_shell, tbuf, (char *)NULL);
+ err(1, "%s", pwd->pw_shell);
+ }