From: Michel Normand Date: Thu, 29 Apr 2010 08:03:58 +0000 (+0200) Subject: close fd 0 and 1 where not required X-Git-Tag: lxc-0.7.0~104 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=affaa6da9dd10a99b9f60e24ceb3a216d56fcba1;p=thirdparty%2Flxc.git close fd 0 and 1 where not required the fd 0,1 and 2 are still inherited and we only need the fd 2 (stderr) after the start/restart of the application. Signed-off-by: Michel Normand Signed-off-by: Daniel Lezcano --- diff --git a/src/lxc/lxc_init.c b/src/lxc/lxc_init.c index 05b429735..b0b7ac7c9 100644 --- a/src/lxc/lxc_init.c +++ b/src/lxc/lxc_init.c @@ -92,6 +92,10 @@ int main(int argc, char *argv[]) exit(err); } + /* no need of other inherited fds but stderr */ + close(fileno(stdin)); + close(fileno(stdout)); + err = 0; for (;;) { int status; diff --git a/src/lxc/start.c b/src/lxc/start.c index 3b5023c9f..7d5763a75 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -547,6 +547,10 @@ int lxc_start(const char *name, char *const argv[], struct lxc_conf *conf) goto out_fini; } + /* no need of other inherited fds but stderr */ + close(fileno(stdin)); + close(fileno(stdout)); + err = lxc_poll(name, handler); if (err) { ERROR("mainloop exited with an error");