From 8adcf3e5d102647e9cc6c4cce7e6d0c7a9f3a9bb Mon Sep 17 00:00:00 2001 From: Michael Walle Date: Sat, 1 Oct 2011 02:29:30 +0200 Subject: [PATCH] set close-on-exec flag on errorlogfile Make sure the file descriptor is closed within the child after forking. Signed-off-by: Michael Walle --- src/log.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/log.c b/src/log.c index d424ffd3..5e1c35eb 100644 --- a/src/log.c +++ b/src/log.c @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include "util.h" #include "log.h" @@ -41,6 +43,9 @@ void init_logging() { } errorfile = fopen(errorfilename, "w"); + if (fcntl(fileno(errorfile), F_SETFD, FD_CLOEXEC)) { + ELOG("Could not set close-on-exec flag\n"); + } } /* -- 2.39.2