]> git.sesse.net Git - cubemap/blobdiff - log.cpp
Set close-on-exec on all file descriptors we open.
[cubemap] / log.cpp
diff --git a/log.cpp b/log.cpp
index 198ceae9f64633031397fe5117deddb2b013404e..cbecba033824cb84c71bbff2d9bb24c8fcd0c6b1 100644 (file)
--- a/log.cpp
+++ b/log.cpp
@@ -1,11 +1,13 @@
 #include <assert.h>
 #include <errno.h>
+#include <fcntl.h>
 #include <stdarg.h>
 #include <stddef.h>
 #include <stdio.h>
 #include <string.h>
 #include <syslog.h>
 #include <time.h>
+#include <unistd.h>
 #include <string>
 #include <vector>
 
@@ -23,7 +25,7 @@ vector<FILE *> log_destinations;
 
 void add_log_destination_file(const string &filename)
 {
-       FILE *fp = fopen(filename.c_str(), "a");
+       FILE *fp = fopen(filename.c_str(), "ae");
        if (fp == nullptr) {
                perror(filename.c_str());
                return;