Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Dec 2016 13:12:18 +0200
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Jilles Tjoelker <jilles@stack.nl>
Cc:        FreeBSD Hackers <freebsd-hackers@freebsd.org>, Jonathan de Boyne Pollard <J.deBoynePollard-newsgroups@NTLWorld.com>, supervision@list.skarnet.org
Subject:   Re: NOTE_TRACK, EVFILT_PROC, kqueue, and subreapers
Message-ID:  <20161212111218.GB54029@kib.kiev.ua>
In-Reply-To: <20161211222328.GC17315@stack.nl>
References:  <20161201125438.15230317@mydesk.domain.cxm> <20161206104020.6b2ebb30@eto-mona.office.smartweb.sk> <20161206102637.1ddd152a@mydesk.domain.cxm> <20161207155638.4b2dd629@eto-mona.office.smartweb.sk> <630ace89-e29b-d0d3-9f15-110d8dc3de08@NTLWorld.com> <20161208132842.5d7940bd@eto-mona.office.smartweb.sk> <f5f47d55-ec8e-75b6-935d-2d0d1111c449@NTLWorld.com> <20161211124637.GA17315@stack.nl> <20161211175451.GV54029@kib.kiev.ua> <20161211222328.GC17315@stack.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Dec 11, 2016 at 11:23:28PM +0100, Jilles Tjoelker wrote:
> On Sun, Dec 11, 2016 at 07:54:51PM +0200, Konstantin Belousov wrote:
> > On Sun, Dec 11, 2016 at 01:46:38PM +0100, Jilles Tjoelker wrote:
> > > As reported in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=213928
> > > reapers do not receive SIGCHLD when inheriting zombies, although they do
> > > receive SIGCHLD when an inherited descendant process later terminates
> > > and are awakened when in a wait call for a matching process. This should
> > > probably be fixed.
> > I agree, in principle.  Could you update your tests/sys/kern/reaper.c to
> > include this scenario ?
> 
> I tested with the patch below. The new test case
> reaper_sigchld_child_first already passes and I have marked
> reaper_sigchld_grandchild_first as an expected timeout.
> 
> > Untested change to the kernel side is below.
> 
> > diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
> > index f4f453c3556..92899740eef 100644
> > --- a/sys/kern/kern_exit.c
> > +++ b/sys/kern/kern_exit.c
> > @@ -455,6 +455,12 @@ exit1(struct thread *td, int rval, int signo)
> >  
> >  		if (!(q->p_flag & P_TRACED)) {
> >  			proc_reparent(q, q->p_reaper);
> > +			if (q->p_state == PRS_ZOMBIE) {
> > +				PROC_LOCK(q->p_reaper);
> > +				pksignal(q->p_reaper, SIGCHLD, q->p_ksi);
> > +				wakeup(q->p_reaper);
> > +				PROC_UNLOCK(q->p_reaper);
> > +			}
> >  		} else {
> >  			/*
> >  			 * Traced processes are killed since their existence
> 
> This change makes reaper_sigchld_grandchild_first pass.
> 
> The wakeup added here is redundant with the one a few lines above:
>         if (q != NULL)          /* only need this if any child is S_ZOMB */
>                 wakeup(q->p_reaper);
I removed additional wakeup, it should be innocent.  Might be the better
change is to remove the lines you cited above and do wakeups inside the
loop after reparenting.  But I kept it that way for now.

> 
> This is also clear because reaper_wait_grandchild_first already passes.
> 
> Index: tests/sys/kern/reaper.c

Thank you, I verified that all tests pass with the patched kernel and
removed timeouts from your reaper_sigchld_*child_first new tests.
The kernel chunk is committed as r309886, please commit tests.



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