From 8fb2af3abc3ad848e70f6ddec0c3b4bd7f12e036 Mon Sep 17 00:00:00 2001 From: mpi Date: Mon, 16 Mar 2020 11:58:46 +0000 Subject: Keep track of traced child under a list of orphans while they are being reparented to a debugger process. Also re-parent exiting traced processes to their original parent, if it is still alive, after the debugger has seen the exit status. Logic comes from FreeBSD pointed out by guenther@. While here rename proc_reparent() into process_reparent() and get rid of superfluous checks. ok visa@ --- sys/kern/kern_fork.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sys/kern/kern_fork.c') diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 613ec3c8d8f..71129dd4079 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_fork.c,v 1.223 2020/02/21 11:10:23 claudio Exp $ */ +/* $OpenBSD: kern_fork.c,v 1.224 2020/03/16 11:58:46 mpi Exp $ */ /* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */ /* @@ -190,6 +190,7 @@ process_initialize(struct process *pr, struct proc *p) KASSERT(p->p_ucred->cr_ref >= 2); /* new thread and new process */ LIST_INIT(&pr->ps_children); + LIST_INIT(&pr->ps_orphans); LIST_INIT(&pr->ps_ftlist); LIST_INIT(&pr->ps_sigiolst); TAILQ_INIT(&pr->ps_tslpqueue); @@ -430,8 +431,7 @@ fork1(struct proc *curp, int flags, void (*func)(void *), void *arg, if (pr->ps_flags & PS_TRACED) { pr->ps_oppid = curpr->ps_pid; - if (pr->ps_pptr != curpr->ps_pptr) - proc_reparent(pr, curpr->ps_pptr); + process_reparent(pr, curpr->ps_pptr); /* * Set ptrace status. -- cgit v1.2.3-59-g8ed1b