+ /*
+ * termination lifecycle events can happen while a debugger
+ * has reparented a process, in which case notifications
+ * should be quashed except to the tracing parent. When
+ * the debugger reaps the child (either via wait4(2) or
+ * process exit), the child will be reparented to the original
+ * parent and these knotes re-fired.
+ */
+ if (event & NOTE_EXIT) {
+ if ((kn->kn_ptr.p_proc->p_oppid != 0)
+ && (kn->kn_kq->kq_p->p_pid != kn->kn_ptr.p_proc->p_ppid)) {
+ /*
+ * This knote is not for the current ptrace(2) parent, ignore.
+ */
+ return 0;
+ }
+ }
+