[lxc-devel] [lxc/master] monitord: close mainloop on exit if we opened it
brauner on Github
lxc-bot at linuxcontainers.org
Tue Nov 29 04:54:46 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20161129/fc4db5ba/attachment.bin>
-------------- next part --------------
From 037a8f6d6785f9cad056717b1ef3011fc4f4ae9e Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Tue, 29 Nov 2016 05:42:47 +0100
Subject: [PATCH] monitord: close mainloop on exit if we opened it
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/lxc_monitord.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/lxc/lxc_monitord.c b/src/lxc/lxc_monitord.c
index 2fbb357..23164a4 100644
--- a/src/lxc/lxc_monitord.c
+++ b/src/lxc/lxc_monitord.c
@@ -344,6 +344,7 @@ static void lxc_monitord_sig_handler(int sig)
int main(int argc, char *argv[])
{
+ bool mainloop_opened;
int ret, pipefd;
char logpath[PATH_MAX];
sigset_t mask;
@@ -395,8 +396,10 @@ int main(int argc, char *argv[])
ERROR("Failed to create mainloop.");
goto on_error;
}
+ mainloop_opened = true;
if (lxc_monitord_create(&mon)) {
+ ERROR("Failed to create monitor.");
goto on_error;
}
@@ -425,14 +428,12 @@ int main(int argc, char *argv[])
}
}
- lxc_mainloop_close(&mon.descr);
- lxc_monitord_cleanup();
+on_signal:
ret = EXIT_SUCCESS;
-
on_error:
- exit(ret);
-
-on_signal:
+ if (mainloop_opened)
+ lxc_mainloop_close(&mon.descr);
lxc_monitord_cleanup();
- exit(EXIT_SUCCESS);
+
+ exit(ret);
}
More information about the lxc-devel
mailing list