Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Feb 2012 18:32:52 +0200
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Dmitry Mikulin <dmitrym@juniper.net>
Cc:        freebsd-current Current <freebsd-current@freebsd.org>, Marcel Moolenaar <marcelm@juniper.net>
Subject:   Re: [ptrace] please review follow fork/exec changes
Message-ID:  <20120215163252.GZ3283@deviant.kiev.zoral.com.ua>
In-Reply-To: <4F3993C5.5020703@juniper.net>
References:  <4F31C89C.7010705@juniper.net> <4F3318AD.6000607@juniper.net> <20120209122908.GD3283@deviant.kiev.zoral.com.ua> <4F34311A.9050702@juniper.net> <20120210001725.GJ3283@deviant.kiev.zoral.com.ua> <4F3478B3.9040809@juniper.net> <20120213152825.GH3283@deviant.kiev.zoral.com.ua> <4F3988E8.2040705@juniper.net> <20120213222521.GK3283@deviant.kiev.zoral.com.ua> <4F3993C5.5020703@juniper.net>

next in thread | previous in thread | raw e-mail | index | archive | help

--VtOb4vV0nsUnkr3G
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Feb 13, 2012 at 02:50:45PM -0800, Dmitry Mikulin wrote:
> >>>It seems that now wait4(2) can be called from the real (non-debugger)
> >>>parent first and result in the call to proc_reap(), isn't it ? We would
> >>>then just reparent the child back to the caller, still leaving the
> >>>zombie and confusing debugger.
> >>When either gdb or the real parent gets to proc_reap() the process=20
> >>wouldn't
> >>get destroyed, it'll get caught by the following clause:
> >>     if (p->p_oppid&&  (t =3D pfind(p->p_oppid)) !=3D NULL) {
> >>
> >>and the real parent with get the child back into the children's list wh=
ile
> >>gdb will get it into the orphan list. The second time around when
> >>proc_reap() is entered, p->p_oppid will be 0 and the process will get
> >>really reaped. Does it make sense? And proc_reparent() attempts to keep=
=20
> >>the
> >>orphan list clean and not have the same entries and the list of sibling=
s.
> >Right, this is what I figured. But I asked about some further implication
> >of this change:
> >
> >if real parent spuriosly calls wait4(2) on the child pid after the child
> >exited, but before the debugger called the wait4(), then exactly the
> >code you noted above will be run. This results in the child being fully
> >returned to the original parent.
> >
> >Next, the wait4() call from debugger gets an error, and zombie will be
> >kept around until parent calls wait4() for this pid once more.
> >
> >Am I missed something ?
>=20
> In this case the process will move from gdb's child list to gdb's orphan=
=20
> list when the real parent does a wait4(). Next time around the wait loop =
in=20
> gdb it'll be caught by the orphan's proc_reap().

I do not see how the next debugger loop could find this process at all,
since the first wait4() call reparented it to the original parent.

--VtOb4vV0nsUnkr3G
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (FreeBSD)

iEYEARECAAYFAk873jQACgkQC3+MBN1Mb4g9UgCg3EUpfudY7esu+R4cGFrYauYh
I7MAoKd6qEKZCGU7SXwWgKWL2kN77QdQ
=QwmM
-----END PGP SIGNATURE-----

--VtOb4vV0nsUnkr3G--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120215163252.GZ3283>