From 454ec0abc7f315fa4894c43488c981f369cacce9 Mon Sep 17 00:00:00 2001 From: Serge Hallyn Date: Tue, 2 Jun 2015 22:33:34 +0000 Subject: [PATCH] api_start: always close fds 0-2 when daemonized MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit 507cee3618237d3 moved the close and re-open of fds 0-2 into do_start. But this means that the lxc monitor itself keeps the caller's fds 0-2 open, which is wrong for daemonized containers. Closes #548 Reported-by: Mathieu Le Marec - Pasquet Signed-off-by: Serge Hallyn Acked-by: Stéphane Graber --- src/lxc/lxccontainer.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index fd56327e6..916c99c91 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -722,6 +722,12 @@ static bool do_lxcapi_start(struct lxc_container *c, int useinit, char * const a return false; } lxc_check_inherited(conf, true, -1); + close(0); + close(1); + close(2); + open("/dev/zero", O_RDONLY); + open("/dev/null", O_RDWR); + open("/dev/null", O_RDWR); setsid(); } else { if (!am_single_threaded()) {