]> git.proxmox.com Git - mirror_lxc.git/commitdiff
c/r: remember to clean up pidfile
authorTycho Andersen <tycho.andersen@canonical.com>
Tue, 2 Jun 2015 03:14:57 +0000 (21:14 -0600)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 2 Jun 2015 23:04:23 +0000 (19:04 -0400)
When restoring, we didn't clean up the pidfile that criu uses to pass us the
init pid on error or success; let's do that.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/criu.c

index 5fbe7cbad5bff3e59f9ea65f3f3eeb13a79f7cfa..c331adf7f126a6107c735509c2064c97b947925e 100644 (file)
@@ -527,6 +527,9 @@ void do_restore(struct lxc_container *c, int pipe, char *directory, bool verbose
 
                                ret = fscanf(f, "%d", (int*) &handler->pid);
                                fclose(f);
+                               if (unlink(pidfile) < 0 && errno != ENOENT)
+                                       SYSERROR("unlinking pidfile failed");
+
                                if (ret != 1) {
                                        ERROR("reading restore pid failed");
                                        goto out_fini_handler;
@@ -557,6 +560,8 @@ void do_restore(struct lxc_container *c, int pipe, char *directory, bool verbose
 
 out_fini_handler:
        lxc_fini(c->name, handler);
+       if (unlink(pidfile) < 0 && errno != ENOENT)
+               SYSERROR("unlinking pidfile failed");
 
 out:
        if (pipe >= 0) {