Re: [ptrace] please review follow fork/exec changes

From: Dmitry Mikulin <dmitrym_at_juniper.net>
Date: Wed, 15 Feb 2012 10:22:13 -0800
I'm not sure we are on the same page. Let's do it from the very beginning.

The real parent calls wait4() and enters kern_wait() while the child is in a zombie state. The child is in the gdb's children list and the real parent's orphan list.

We enter proc_reap() because the child is caught by the orphan list of the real parent.
We are at
     if (p->p_oppid && (t = pfind(p->p_oppid)) != NULL) {
doing proc_reparent() to the real parent of the child.
The child is in the real parent's orphan list and will be removed from it by proc_reparent and added to the orphan list of gdb.

After we're done re-parenting, the child is in the children list of the real parent and in the orphan list of gdb.
On the way out of proc_reap we clear p->p_oppid and wait4() returns the exit code to the real parent.

The child is not yet destroyed and is being waited for by gdb since it's on gdb's orphan list. We enter proc_reap() through gdb's wait4() and kern_wait().
We don't enter the following this time
     if (p->p_oppid && (t = pfind(p->p_oppid)) != NULL) {
and go to the actual destruction of the process.
Received on Wed Feb 15 2012 - 17:24:08 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:24 UTC