aboutsummaryrefslogtreecommitdiffstats
path: root/src/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/log.c')
-rw-r--r--src/log.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/log.c b/src/log.c
index 94691ab64..bb1f1f112 100644
--- a/src/log.c
+++ b/src/log.c
@@ -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);
}