set close-on-exec flag on errorlogfile

Make sure the file descriptor is closed within the child after forking.

Signed-off-by: Michael Walle <michael@walle.cc>
This commit is contained in:
Michael Walle 2011-10-01 02:29:30 +02:00 committed by Michael Stapelberg
parent 6ce2f4d394
commit 8adcf3e5d1
1 changed files with 5 additions and 0 deletions

View File

@ -16,6 +16,8 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/time.h> #include <sys/time.h>
#include <unistd.h>
#include <fcntl.h>
#include "util.h" #include "util.h"
#include "log.h" #include "log.h"
@ -41,6 +43,9 @@ void init_logging() {
} }
errorfile = fopen(errorfilename, "w"); errorfile = fopen(errorfilename, "w");
if (fcntl(fileno(errorfile), F_SETFD, FD_CLOEXEC)) {
ELOG("Could not set close-on-exec flag\n");
}
} }
/* /*