diff options
author | Evan Martin <martine@danga.com> | 2011-10-31 22:30:29 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2011-10-31 22:39:53 (GMT) |
commit | a6212990930c1ca85488bada1936ce41aac34364 (patch) | |
tree | e1c84770f336b6ce3cd2671473709580374e7ebe /src/build_log.cc | |
parent | afbe2185a3bbd2453d6b1c27ee8f7c1cce6371a3 (diff) | |
download | Ninja-a6212990930c1ca85488bada1936ce41aac34364.zip Ninja-a6212990930c1ca85488bada1936ce41aac34364.tar.gz Ninja-a6212990930c1ca85488bada1936ce41aac34364.tar.bz2 |
move SetCloseOnExec to util
Diffstat (limited to 'src/build_log.cc')
-rw-r--r-- | src/build_log.cc | 19 |
1 files changed, 2 insertions, 17 deletions
diff --git a/src/build_log.cc b/src/build_log.cc index 79143bf..43d5f01 100644 --- a/src/build_log.cc +++ b/src/build_log.cc @@ -15,13 +15,13 @@ #include "build_log.h" #include <errno.h> -#include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "build.h" #include "graph.h" +#include "util.h" // Implementation details: // Each run's log appends to the log file. @@ -35,21 +35,6 @@ namespace { const char kFileSignature[] = "# ninja log v2\n"; const int kCurrentVersion = 2; -void SetCloseOnExec(FILE* file) { -#ifndef _WIN32 - int flags = fcntl(fileno(file), F_GETFD); - if (flags < 0) { - perror("fcntl(F_GETFD)"); - } else { - if (fcntl(fileno(file), F_SETFD, flags | FD_CLOEXEC) < 0) - perror("fcntl(F_SETFD)"); - } -#else - // On Windows, handles must be explicitly marked to be passed to a - // spawned process, so there's nothing to do here. -#endif // WIN32 -} - } BuildLog::BuildLog() @@ -71,7 +56,7 @@ bool BuildLog::OpenForWrite(const string& path, string* err) { return false; } setvbuf(log_file_, NULL, _IOLBF, BUFSIZ); - SetCloseOnExec(log_file_); + SetCloseOnExec(fileno(log_file_)); if (ftell(log_file_) == 0) { if (fwrite(kFileSignature, sizeof(kFileSignature) - 1, 1, log_file_) < 1) { |