]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Don't leak log file descriptor to executed commands
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 5 Jan 2013 15:47:04 +0000 (16:47 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 5 Jan 2013 15:47:04 +0000 (16:47 +0100)
util.c

diff --git a/util.c b/util.c
index 66be67d733accddea7a860c1c513ee1422b64769..3b472def20976e81f688593ebd66586eb6962d02 100644 (file)
--- a/util.c
+++ b/util.c
@@ -48,6 +48,11 @@ init_log(void)
        }
        logfile = fopen(cache_logfile, "a");
        if (logfile) {
+               int fd = fileno(logfile);
+               int flags = fcntl(fd, F_GETFD, 0);
+               if (flags >= 0) {
+                       fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
+               }
                return true;
        } else {
                return false;