diff options
Diffstat (limited to 'src/log.c')
-rw-r--r-- | src/log.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -20,6 +20,7 @@ #include "log.h" #include "conf.h" #include "utils.h" +#include "fd_util.h" #include "config.h" #include <assert.h> @@ -128,7 +129,7 @@ open_log_file(void) { assert(out_filename != NULL); - return open(out_filename, O_CREAT | O_WRONLY | O_APPEND, 0666); + return open_cloexec(out_filename, O_CREAT | O_WRONLY | O_APPEND, 0666); } static void @@ -271,7 +272,10 @@ void setup_log_output(bool use_stdout) { fflush(NULL); if (!use_stdout) { - if (out_filename != NULL) { + if (out_filename == NULL) + out_fd = open("/dev/null", O_WRONLY); + + if (out_fd >= 0) { redirect_logs(out_fd); close(out_fd); } |