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 <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
This commit is contained in:
Michel Normand 2010-04-29 10:03:58 +02:00 committed by Daniel Lezcano
parent 698287d8cf
commit affaa6da9d
2 changed files with 8 additions and 0 deletions

View File

@ -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;

View File

@ -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");