projects
/
platform
/
upstream
/
ninja.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
eca6bbe
)
Add a Windows version of SetCloseOnExec()
author
Qingning Huo
<qingninghuo@gmail.com>
Tue, 13 Mar 2012 23:28:44 +0000
(23:28 +0000)
committer
Qingning Huo
<qingninghuo@gmail.com>
Tue, 13 Mar 2012 23:28:44 +0000
(23:28 +0000)
src/util.cc
patch
|
blob
|
history
diff --git
a/src/util.cc
b/src/util.cc
index 02be994b0ce0cd24c731dddf4ffd16798ad17894..4d9adf3f5b4ffe78a694f4702ddd919ced071304 100644
(file)
--- 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
}