[lxc-devel] [PATCH] lxc-checkpoint -r should actually wait for the restore to happen

Serge Hallyn serge.hallyn at ubuntu.com
Tue Mar 24 19:40:48 UTC 2015


Quoting Tycho Andersen (tycho.andersen at canonical.com):
> On Fri, Mar 20, 2015 at 08:38:39PM +0000, Serge Hallyn wrote:
> > Quoting Tycho Andersen (tycho.andersen at canonical.com):
> > > From: Tycho Andersen <tycho.andersen at canonical.com>
> > > 
> > > Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
> > > ---
> > >  src/lxc/lxc_checkpoint.c | 20 ++++++++++++++++++++
> > >  1 file changed, 20 insertions(+)
> > > 
> > > diff --git a/src/lxc/lxc_checkpoint.c b/src/lxc/lxc_checkpoint.c
> > > index cfa08fc..8345789 100644
> > > --- a/src/lxc/lxc_checkpoint.c
> > > +++ b/src/lxc/lxc_checkpoint.c
> > > @@ -20,6 +20,8 @@
> > >  #include <stdio.h>
> > >  #include <errno.h>
> > >  #include <unistd.h>
> > > +#include <sys/types.h>
> > > +#include <sys/wait.h>
> > >  
> > >  #include <lxc/lxccontainer.h>
> > >  
> > > @@ -168,6 +170,24 @@ bool restore(struct lxc_container *c)
> > >  
> > >  	lxc_container_put(c);
> > >  
> > > +	if (pid != 0) {
> > > +		int status;
> > > +		pid_t w;
> > 
> > hi,
> > 
> > what about using wait_for_pid(pid) here?
> 
> Ah ha, very nice.
> 
> Tycho
> 
> 
> From 00b210556242f1e688a256e805be433b34e1063c Mon Sep 17 00:00:00 2001
> From: Tycho Andersen <tycho.andersen at canonical.com>
> Date: Fri, 20 Mar 2015 10:17:31 -0600
> Subject: [PATCH] lxc-checkpoint -r should actually wait for the restore to
>  happen
> 
> Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
> ---
>  src/lxc/lxc_checkpoint.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/lxc/lxc_checkpoint.c b/src/lxc/lxc_checkpoint.c
> index cfa08fc..e271199 100644
> --- a/src/lxc/lxc_checkpoint.c
> +++ b/src/lxc/lxc_checkpoint.c
> @@ -27,6 +27,7 @@
>  #include "config.h"
>  #include "lxc.h"
>  #include "arguments.h"
> +#include "utils.h"
>  
>  static char *checkpoint_dir = NULL;
>  static bool stop = false;
> @@ -168,6 +169,9 @@ bool restore(struct lxc_container *c)
>  
>  	lxc_container_put(c);
>  
> +	if (pid != 0)
> +		wait_for_pid(pid);

Sorry - I suspect some package builds will fail on the ignore of
return value here.  Could this be

	if (pid != 0)
		return wait_for_pid(pid) == 0;

> +
>  	return ret;
>  }
>  
> -- 
> 2.1.0
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel


More information about the lxc-devel mailing list