As exposed recently via the t_ptrace regression and some make changes an
exit status might reported twice to its parent via wait(2).

The diff below fixes that by making sure we do not re-parent a child to
the same parent.

With it the above mentioned regression as well as the ptrace one that
I'm porting from FreeBSD pass.

ok?


Index: kern/kern_exit.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_exit.c,v
retrieving revision 1.182
diff -u -p -r1.182 kern_exit.c
--- kern/kern_exit.c    19 Dec 2019 17:40:10 -0000      1.182
+++ kern/kern_exit.c    6 Feb 2020 11:02:01 -0000
@@ -584,7 +584,8 @@ proc_finish_wait(struct proc *waiter, st
         * we need to give it back to the old parent.
         */
        pr = p->p_p;
-       if (pr->ps_oppid && (tr = prfind(pr->ps_oppid))) {
+       if (pr->ps_oppid != 0 && (pr->ps_oppid != pr->ps_pptr->ps_pid) &&
+          (tr = prfind(tr->ps_oppid))) {
                atomic_clearbits_int(&pr->ps_flags, PS_TRACED);
                pr->ps_oppid = 0;
                proc_reparent(pr, tr);

Reply via email to