diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2011-12-20 08:59:09 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2011-12-20 08:59:09 +0000 |
commit | b51df176a874c7c360a3584d3d3fa2c02d7c68b4 (patch) | |
tree | a0f2dcfe63707ef2fe47647ae9bb7a05067bbb7c | |
parent | ca0c2369197920fa945f03d71c918dc62bb1ae0b (diff) |
PR#5416: better implementation of set/clear_close_on_exec
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11888 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | Changes | 1 | ||||
-rw-r--r-- | otherlibs/win32unix/close_on.c | 13 |
2 files changed, 6 insertions, 8 deletions
@@ -31,6 +31,7 @@ Standard library: with user-provided hash functions. Bug Fixes: +- PR#5416: (Windows) Unix.(set|clear)_close_on_exec now preserves blocking mode - PR#5343: ocaml -rectypes is unsound wrt module subtyping - PR#5322: type abbreviations expanding to a universal type variable - PR#5330: thread tag with '.top' and '.inferred.mli' targets diff --git a/otherlibs/win32unix/close_on.c b/otherlibs/win32unix/close_on.c index b64dd44dd..03ff2b894 100644 --- a/otherlibs/win32unix/close_on.c +++ b/otherlibs/win32unix/close_on.c @@ -19,17 +19,14 @@ int win_set_inherit(value fd, BOOL inherit) { - HANDLE oldh, newh; - - oldh = Handle_val(fd); - if (! DuplicateHandle(GetCurrentProcess(), oldh, - GetCurrentProcess(), &newh, - 0L, inherit, DUPLICATE_SAME_ACCESS)) { + /* According to the MSDN, SetHandleInformation may not work + for console handles on WinNT4 and earlier versions. */ + if (! SetHandleInformation(Handle_val(fd), + HANDLE_FLAG_INHERIT, + inherit ? HANDLE_FLAG_INHERIT : 0)) { win32_maperr(GetLastError()); return -1; } - Handle_val(fd) = newh; - CloseHandle(oldh); return 0; } |