[lxc-devel] [PATCH] Fix fd leak in lxc log
Dwight Engen
dwight.engen at oracle.com
Mon Nov 26 17:17:51 UTC 2012
lxc_log_init will leak an fd when it is called by a long running
program that may call lxc_container_new multiple times. Fix by
only opening the log if it is not already open.
Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
---
src/lxc/log.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/src/lxc/log.c b/src/lxc/log.c
index 7f3b6b2..02ee21c 100644
--- a/src/lxc/log.c
+++ b/src/lxc/log.c
@@ -153,6 +153,9 @@ extern int lxc_log_init(const char *file, const char *priority,
{
int lxc_priority = LXC_LOG_PRIORITY_ERROR;
+ if (lxc_log_fd != -1)
+ return 0;
+
if (priority) {
lxc_priority = lxc_log_priority_to_int(priority);
--
1.7.1
More information about the lxc-devel
mailing list