Commit 781b069e authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Don't close HANDLE if stdout or stderr is sharing it.

Based on Qian Hong patch. Signed-off-by: 's avatarPiotr Caban <piotr@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 3fb8ec59
......@@ -1021,6 +1021,14 @@ int CDECL MSVCRT__close(int fd)
TRACE(":fd (%d) handle (%p)\n", fd, info->handle);
if (!(info->wxflag & WX_OPEN)) {
ret = -1;
} else if (fd == MSVCRT_STDOUT_FILENO &&
info->handle == get_ioinfo_nolock(MSVCRT_STDERR_FILENO)->handle) {
msvcrt_free_fd(fd);
ret = 0;
} else if (fd == MSVCRT_STDERR_FILENO &&
info->handle == get_ioinfo_nolock(MSVCRT_STDOUT_FILENO)->handle) {
msvcrt_free_fd(fd);
ret = 0;
} else {
ret = CloseHandle(info->handle) ? 0 : -1;
msvcrt_free_fd(fd);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment