[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH] xl: close nullfd after dup2'ing it to stdin
Taking care not to do so if nullfd happens (somehow) to have the same fd number as stdin/out/err. CID: 1130519 It was previously hypothesised[0] that fixing 1130516 would solve this too, but that appears to not have been the case. Compile tested only. [0] http://lists.xenproject.org/archives/html/xen-devel/2013-11/msg02931.html Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> Cc: andrew.cooper3@xxxxxxxxxx --- tools/libxl/xl_cmdimpl.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index d07ccb2..f38e3dd 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -505,6 +505,16 @@ static int do_daemonize(char *name, const char *pidfile) dup2(logfile, 1); dup2(logfile, 2); + /* Close nullfd unless it happens to == std{in,out,err} */ + switch (nullfd) { + case 0: + case 1: + case 2: + break; + default: + close(nullfd); + } + CHK_SYSCALL(daemon(0, 1)); if (pidfile) { -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |