+ /* We've simulated the exit, so we have to cancel the kevent for
+ * this job, otherwise we may get a kevent later down the road that
+ * has a stale context pointer (if we've removed the job). Or worse,
+ * it'll corrupt our data structures if the job still exists or the
+ * allocation was recycled.
+ *
+ * If the failing process had a tracer attached to it, we need to
+ * remove out NOTE_EXIT for that tracer too, otherwise the same
+ * thing might happen.
+ *
+ * Note that, if we're not shutting down, this will result in a
+ * zombie process just hanging around forever. But if the process
+ * didn't exit after receiving SIGKILL, odds are it would've just
+ * stuck around forever anyway.
+ *
+ * See <rdar://problem/9481630>.
+ */
+ kevent_mod((uintptr_t)j->p, EVFILT_PROC, EV_DELETE, 0, 0, NULL);
+ if (j->tracing_pid) {
+ kevent_mod((uintptr_t)j->tracing_pid, EVFILT_PROC, EV_DELETE, 0, 0, NULL);
+ }
+