On Sat, Dec 14, 2013 at 12:04:24PM +0200, Kevin Wilson wrote: > Hello, > Could anybody please explain: > In create_run_template() , > https://github.com/lxc/lxc/blob/master/src/lxc/lxccontainer.c > > we have: > > if (quiet) { > close(0); > close(1); > close(2); > open("/dev/zero", O_RDONLY); > open("/dev/null", O_RDWR); > open("/dev/null", O_RDWR); > } > > Why do we need twice to call open("/dev/null", O_RDWR) ? Is it have > to do with running as daemon ? or is it redundant ? > We don't use the returned fd in both cases. > > Kevin
The code above closes the 3 standard fds: - 0 => stdin - 1 => stdout - 2 => stderr And then re-opens them with correct values to hide any output from the script. So that line isn't redundant at all, if it was missing, I'd expect the code to crash when something would try to write to stderr. -- Stéphane Graber Ubuntu developer http://www.ubuntu.com
signature.asc
Description: Digital signature
_______________________________________________ lxc-devel mailing list [email protected] http://lists.linuxcontainers.org/listinfo/lxc-devel
