[lxc-devel] [PATCH] lxc-checkpoint -r should actually wait for the restore to happen
Tycho Andersen
tycho.andersen at canonical.com
Fri Mar 20 16:35:20 UTC 2015
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;
+
+ 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
More information about the lxc-devel
mailing list