[lxc-devel] [PATCH] lxc-checkpoint -r should actually wait for the restore to happen
Serge Hallyn
serge.hallyn at ubuntu.com
Fri Mar 20 20:38:39 UTC 2015
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?
(It's in src/lxc/utils.c)
> + w = waitpid(pid, &status, 0);
> + if (w == -1) {
> + perror("waitpid");
> + return false;
> + }
> +
> + if (WIFEXITED(status)) {
> + return status == 0;
> + } else {
> + fprintf(stderr, "restore process was killed with signal %d\n", WTERMSIG(status));
> + return false;
> + }
> + }
> +
> 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