summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
}