summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2012-03-13 23:37:53 (GMT)
committerEvan Martin <martine@danga.com>2012-03-13 23:37:53 (GMT)
commitfdec96f54e92d2990ebf1ba5434b317d3d8ad49d (patch)
tree10f82c67c7680b3c74e014a79b343d74ed4e381a /src
parent898d2f20f9690a853e4b71e5b223dc18f324508c (diff)
parent4548ee03f1e6495751dfe31fa2bf416819257ce4 (diff)
downloadNinja-fdec96f54e92d2990ebf1ba5434b317d3d8ad49d.zip
Ninja-fdec96f54e92d2990ebf1ba5434b317d3d8ad49d.tar.gz
Ninja-fdec96f54e92d2990ebf1ba5434b317d3d8ad49d.tar.bz2
Merge pull request #250 from qhuo/SetCloseOnExec-for-Windows
Add a Windows version of SetCloseOnExec()
Diffstat (limited to 'src')
-rw-r--r--src/util.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/util.cc b/src/util.cc
index 02be994..4d9adf3 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -197,9 +197,10 @@ void SetCloseOnExec(int fd) {
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.
- NINJA_UNUSED_ARG(fd);
+ HANDLE hd = (HANDLE) _get_osfhandle(fd);
+ if (! SetHandleInformation(hd, HANDLE_FLAG_INHERIT, 0)) {
+ fprintf(stderr, "SetHandleInformation(): %s", GetLastErrorString().c_str());
+ }
#endif // ! _WIN32
}