summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2020-02-12 14:41:24 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2020-02-12 14:41:24 +0000
commit57e23cc93e7bdf6acca7852d972f777f5687d506 (patch)
tree45a3d5dfc92a53d80df6b7048e1c7feb028c935d /sys
parent758e0bf6ad9d426618ee8dc337d2e53666f59022 (diff)
Do not reparent a traced child to ourself inside wait(2).
When a traced process _exit(2)s, its (tracing) parent tries to give it back to the old parent. In the case where the old parent is the same as the tracing parent, there's no need to do this dance, so simply remove it from the list of zombies and free its descriptors. Fix a double report via wait(2) exposed by recent changes in make and newly imported ptrace(2) regression from NetBSD. Diagnosed with espie@ and guenther@, ok claudio@
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_exit.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 3f851fd2a9a..2481aaaf5a0 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_exit.c,v 1.182 2019/12/19 17:40:10 mpi Exp $ */
+/* $OpenBSD: kern_exit.c,v 1.183 2020/02/12 14:41:23 mpi Exp $ */
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
/*
@@ -584,7 +584,8 @@ proc_finish_wait(struct proc *waiter, struct proc *p)
* 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);