Report error during error log creation (#2625)

next
Jens-Wolfhard Schicke-Uffmann 2017-01-10 09:29:06 +01:00 committed by Michael Stapelberg
parent 6da187b27f
commit 584263b1b3
1 changed files with 7 additions and 2 deletions

View File

@ -88,8 +88,13 @@ void init_logging(void) {
fprintf(stderr, "Could not initialize errorlog\n");
else {
errorfile = fopen(errorfilename, "w");
if (fcntl(fileno(errorfile), F_SETFD, FD_CLOEXEC)) {
fprintf(stderr, "Could not set close-on-exec flag\n");
if (!errorfile) {
fprintf(stderr, "Could not initialize errorlog on %s: %s\n",
errorfilename, strerror(errno));
} else {
if (fcntl(fileno(errorfile), F_SETFD, FD_CLOEXEC)) {
fprintf(stderr, "Could not set close-on-exec flag\n");
}
}
}
}