Commit 5b3105f5 by Tycho Andersen Committed by Stéphane Graber

don't hang on some errors in do_restore

Instead, the parent always writes a status to the pipe. Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com> Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
parent c9d8f2ee
...@@ -4066,13 +4066,14 @@ static void do_restore(struct lxc_container *c, int pipe, char *directory, bool ...@@ -4066,13 +4066,14 @@ static void do_restore(struct lxc_container *c, int pipe, char *directory, bool
pid_t pid; pid_t pid;
char pidfile[L_tmpnam]; char pidfile[L_tmpnam];
struct lxc_handler *handler; struct lxc_handler *handler;
int status;
if (!tmpnam(pidfile)) if (!tmpnam(pidfile))
exit(1); goto out;
handler = lxc_init(c->name, c->lxc_conf, c->config_path); handler = lxc_init(c->name, c->lxc_conf, c->config_path);
if (!handler) if (!handler)
exit(1); goto out;
if (!cgroup_init(handler)) { if (!cgroup_init(handler)) {
ERROR("failed initing cgroups"); ERROR("failed initing cgroups");
...@@ -4097,6 +4098,9 @@ static void do_restore(struct lxc_container *c, int pipe, char *directory, bool ...@@ -4097,6 +4098,9 @@ static void do_restore(struct lxc_container *c, int pipe, char *directory, bool
struct criu_opts os; struct criu_opts os;
struct lxc_rootfs *rootfs; struct lxc_rootfs *rootfs;
close(pipe);
pipe = -1;
if (unshare(CLONE_NEWNS)) if (unshare(CLONE_NEWNS))
goto out_fini_handler; goto out_fini_handler;
...@@ -4130,7 +4134,7 @@ static void do_restore(struct lxc_container *c, int pipe, char *directory, bool ...@@ -4130,7 +4134,7 @@ static void do_restore(struct lxc_container *c, int pipe, char *directory, bool
rmdir(rootfs->mount); rmdir(rootfs->mount);
goto out_fini_handler; goto out_fini_handler;
} else { } else {
int status, ret; int ret;
char title[2048]; char title[2048];
pid_t w = waitpid(pid, &status, 0); pid_t w = waitpid(pid, &status, 0);
...@@ -4141,6 +4145,7 @@ static void do_restore(struct lxc_container *c, int pipe, char *directory, bool ...@@ -4141,6 +4145,7 @@ static void do_restore(struct lxc_container *c, int pipe, char *directory, bool
ret = write(pipe, &status, sizeof(status)); ret = write(pipe, &status, sizeof(status));
close(pipe); close(pipe);
pipe = -1;
if (sizeof(status) != ret) { if (sizeof(status) != ret) {
perror("write"); perror("write");
...@@ -4192,6 +4197,16 @@ static void do_restore(struct lxc_container *c, int pipe, char *directory, bool ...@@ -4192,6 +4197,16 @@ static void do_restore(struct lxc_container *c, int pipe, char *directory, bool
out_fini_handler: out_fini_handler:
lxc_fini(c->name, handler); lxc_fini(c->name, handler);
out:
if (pipe >= 0) {
status = 1;
if (write(pipe, &status, sizeof(status)) != sizeof(status)) {
SYSERROR("writing status failed");
}
close(pipe);
}
exit(1); exit(1);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment