[CRIU] [PATCH 11/14] restore: collect signals from zombies (v4)

Andrew Vagin avagin at parallels.com
Mon Mar 25 13:58:01 EDT 2013


On Mon, Mar 25, 2013 at 08:51:46PM +0400, Pavel Emelyanov wrote:
> On 03/25/2013 06:37 PM, Andrey Vagin wrote:
> > Each zombie sends SIGCHLD to parent. crtools restores all pending
> > signals, so all other signals should be collected.
> > 
> > Here is a problems, that signals SIGCHLD can be merged, but crtools
> > should be sure, that all signals are collected.
> > 
> > For that a zombie locks a global zombie_lock, which is released by
> > parent.
> > 
> > This operation should be done between CR_STATE_RESTORE and
> > CR_STATE_RESTORE_SIGCHLD.
> > 
> > Here is one more CR_STATE_RESTORE_ZOMBIES, whic is used for waiting all
> > zombies.
> > 
> > v2: clean up
> > v3: rework synchronization
> > v4: rework without additional CR_STATE-s
> > 
> > Signed-off-by: Andrey Vagin <avagin at openvz.org>
> > ---
> >  cr-restore.c       |  4 +++-
> >  include/restorer.h |  2 ++
> >  pie/restorer.c     | 14 ++++++++++++++
> >  3 files changed, 19 insertions(+), 1 deletion(-)
> > 
> > diff --git a/cr-restore.c b/cr-restore.c
> > index 7454f59..5322f28 100644
> > --- a/cr-restore.c
> > +++ b/cr-restore.c
> > @@ -696,7 +696,7 @@ static int restore_one_zombie(int pid, int exit_code)
> >  	if (task_entries != NULL) {
> >  		restore_finish_stage(CR_STATE_RESTORE);
> >  		zombie_prepare_signals();
> > -		restore_finish_stage(CR_STATE_RESTORE_SIGCHLD);
> 
> Stages engine rely on zombies to finish this stage. Who will update one?

The parent will decrement nr_in_progress in the sigchild_handler

> 
> > +		mutex_lock(&task_entries->zombie_lock);
> >  	}
> >  
> >  	if (exit_code & 0x7f) {
> > @@ -1263,6 +1263,7 @@ static int prepare_task_entries()
> >  	task_entries->nr_tasks = 0;
> >  	task_entries->nr_helpers = 0;
> >  	futex_set(&task_entries->start, CR_STATE_FORKING);
> > +	mutex_init(&task_entries->zombie_lock);
> 
> So, the first zombie will die right after it gets to the code in restore_one_zombie.
> Will parent be ready for that?

Yes, it will. Currently here is only one sigchld_handler in restorer and
if task_entries->start is CR_STATE_RESTORE_SIGCHLD it handles zombies,
otherwise it reports errors, because someone has exited unexpectedly.

> 
> >  	return 0;
> >  }


More information about the CRIU mailing list