[CRIU] [PATCHv1 1/2] restorer: implement restore of ps tree in stopped state

Batalov Eugene eabatalov89 at gmail.com
Mon May 16 13:02:33 PDT 2016


2016-05-16 21:48 GMT+03:00 Andrew Vagin <avagin at virtuozzo.com>:

> On Mon, May 02, 2016 at 06:46:05PM +0300, Eugene Batalov wrote:
> > From: Kravchenko Dmitrii <equivalence1 at gmail.com>
> >
> > This patch adds implementation of --leave-stopped option
> > to CRIU restore cmd. If --leave-stopped is passed then
> > each process in ps tree gets SIGSTOP before detaching
> > from it.
> >
> > Signed-off-by: Kravchenko Dmitrii <equivalence1 at gmail.com>
> > Signed-off-by: Eugene Batalov <eabatalov89 at gmail.com>
> > ---
> >  criu/cr-restore.c |  3 ++-
> >  criu/crtools.c    | 10 ++++++++++
> >  2 files changed, 12 insertions(+), 1 deletion(-)
> >
> > diff --git a/criu/cr-restore.c b/criu/cr-restore.c
> > index ac0943b..d212abe 100644
> > --- a/criu/cr-restore.c
> > +++ b/criu/cr-restore.c
> > @@ -1924,7 +1924,8 @@ static void finalize_restore(void)
> >
> >               xfree(ctl);
> >
> > -             if (item->pid.state == TASK_STOPPED)
> > +             if ((item->pid.state == TASK_STOPPED) ||
> > +                             (opts.final_state == TASK_STOPPED))
> >                       kill(item->pid.real, SIGSTOP);
> >       }
> >  }
> > diff --git a/criu/crtools.c b/criu/crtools.c
> > index 7a0f977..be33f4c 100644
> > --- a/criu/crtools.c
> > +++ b/criu/crtools.c
> > @@ -688,6 +688,16 @@ int main(int argc, char *argv[], char *envp[])
> >                       return 1;
> >       }
> >
> > +     /*
> > +      * When a process group becomes an orphan,
> > +      * its processes are sent a SIGHUP signal
> > +      */
> > +     if (!strcmp(argv[optind], "restore") &&
> > +                     opts.restore_detach &&
> > +                     opts.final_state == TASK_STOPPED &&
> > +                     opts.shell_job)
> > +             pr_warn("Stopped and detached shell job will get SIGHUP
> from OS.");
>
> Why does this specific for TASK_STOPPED?
>

I've checked this thing better.
SIGHUP is only sent when a process is stopped. So I think my comment
> +     /*
> +      * When a process group becomes an orphan,
> +      * its processes are sent a SIGHUP signal
> +      */
is not precise enough. Do you think we need to make it more precise?

Reference in POSIX to the subject: http://linux.die.net/man/2/getpgrp

> If the exit of the process causes a process group to become orphaned, and
> if any member of the newly orphaned process group is stopped, then a SIGHUP
> signal followed by a SIGCONT signal will be sent to each process in the
> newly orphaned process group. An orphaned process group is one in which the
> parent of every member of process group is either itself also a member of
> the process group or is a member of a process group in a different session



> > +
> >       if (chdir(work_dir)) {
> >               pr_perror("Can't change directory to %s", work_dir);
> >               return 1;
> > --
> > 1.9.1
> >
> > _______________________________________________
> > CRIU mailing list
> > CRIU at openvz.org
> > https://lists.openvz.org/mailman/listinfo/criu
>



-- 
Best regards,
Eugene Batalov.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvz.org/pipermail/criu/attachments/20160516/8b3ae0da/attachment.html>


More information about the CRIU mailing list