mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 17:05:46 +00:00
Honour the inheritance of a handle if it would be duplicated or opened.
svn path=/trunk/; revision=17295
This commit is contained in:
parent
7faccfa7bb
commit
52f95df613
2 changed files with 5 additions and 3 deletions
|
@ -13,25 +13,27 @@ int _dup(int handle)
|
|||
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);
|
||||
|
|
|
@ -523,7 +523,7 @@ int __fileno_dup2(int handle1, int handle2)
|
|||
hProcess,
|
||||
&fdinfo(handle2)->hFile,
|
||||
0,
|
||||
TRUE,
|
||||
fdinfo(handle1)->fdflags & FNOINHERIT ? FALSE : TRUE,
|
||||
DUPLICATE_SAME_ACCESS);
|
||||
if (result) {
|
||||
// _pioinfo[handle2]->fd = handle2;
|
||||
|
|
Loading…
Reference in a new issue