summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQingning Huo <qingninghuo@gmail.com>2012-03-13 23:28:44 (GMT)
committerQingning Huo <qingninghuo@gmail.com>2012-03-13 23:28:44 (GMT)
commit4548ee03f1e6495751dfe31fa2bf416819257ce4 (patch)
tree9ea48aa91cac4661118d79381334a02073502d54 /src
parenteca6bbe32bf3d1263ed1173a774f9d91c9b0f415 (diff)
downloadNinja-4548ee03f1e6495751dfe31fa2bf416819257ce4.zip
Ninja-4548ee03f1e6495751dfe31fa2bf416819257ce4.tar.gz
Ninja-4548ee03f1e6495751dfe31fa2bf416819257ce4.tar.bz2
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
}