summaryrefslogtreecommitdiffstats
path: root/otherlibs/win32unix
diff options
context:
space:
mode:
Diffstat (limited to 'otherlibs/win32unix')
-rw-r--r--otherlibs/win32unix/close_on.c13
1 files changed, 5 insertions, 8 deletions
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;
}