[lxc-devel] [PATCH] c/r: remember to clean up pidfile

Tycho Andersen tycho.andersen at canonical.com
Tue Jun 2 03:14:57 UTC 2015


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 at canonical.com>
---
 src/lxc/criu.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/lxc/criu.c b/src/lxc/criu.c
index 1913473..d45c96c 100644
--- a/src/lxc/criu.c
+++ b/src/lxc/criu.c
@@ -526,6 +526,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;
@@ -556,6 +559,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) {
-- 
2.1.4



More information about the lxc-devel mailing list