Honour the inheritance of a handle if it would be duplicated or opened. Modified: trunk/reactos/lib/crt/io/dup.c Modified: trunk/reactos/lib/crt/io/open.c _____
Modified: trunk/reactos/lib/crt/io/dup.c --- trunk/reactos/lib/crt/io/dup.c 2005-08-11 19:32:02 UTC (rev 17294) +++ trunk/reactos/lib/crt/io/dup.c 2005-08-11 19:37:29 UTC (rev 17295) @@ -13,25 +13,27 @@
HANDLE hProcess = GetCurrentProcess(); BOOL result; int fd; + int mode;
hFile = (HANDLE)_get_osfhandle(handle); if (hFile == INVALID_HANDLE_VALUE) { __set_errno(EBADF); return -1; } + mode = __fileno_getmode(handle); result = DuplicateHandle(hProcess, hFile, hProcess, &hFile, 0, - TRUE, + mode & FNOINHERIT ? FALSE : TRUE, DUPLICATE_SAME_ACCESS); if (result == FALSE) { _dosmaperr(GetLastError()); return -1; }
- fd = alloc_fd(hFile, __fileno_getmode(handle)); + fd = alloc_fd(hFile, mode); if (fd < 0) { CloseHandle(hFile); _____
Modified: trunk/reactos/lib/crt/io/open.c --- trunk/reactos/lib/crt/io/open.c 2005-08-11 19:32:02 UTC (rev 17294) +++ trunk/reactos/lib/crt/io/open.c 2005-08-11 19:37:29 UTC (rev 17295) @@ -523,7 +523,7 @@
hProcess, &fdinfo(handle2)->hFile, 0, - TRUE, + fdinfo(handle1)->fdflags & FNOINHERIT ? FALSE : TRUE, DUPLICATE_SAME_ACCESS); if (result) { // _pioinfo[handle2]->fd = handle2;