Jacek Caban : kernelbase: Duplicate input and output handles to ensure that they are inheritable.
Alexandre Julliard
julliard at winehq.org
Thu Sep 24 15:49:06 CDT 2020
Module: wine
Branch: master
Commit: 0e3edfd9422b811bc9b4c90110133fa342ae204e
URL: https://source.winehq.org/git/wine.git/?a=commit;h=0e3edfd9422b811bc9b4c90110133fa342ae204e
Author: Jacek Caban <jacek at codeweavers.com>
Date: Thu Sep 24 17:26:58 2020 +0200
kernelbase: Duplicate input and output handles to ensure that they are inheritable.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/kernelbase/console.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/dlls/kernelbase/console.c b/dlls/kernelbase/console.c
index ce041020a3..502fbcddaf 100644
--- a/dlls/kernelbase/console.c
+++ b/dlls/kernelbase/console.c
@@ -1732,6 +1732,7 @@ HRESULT WINAPI CreatePseudoConsole( COORD size, HANDLE input, HANDLE output, DWO
{
SECURITY_ATTRIBUTES inherit_attr = { sizeof(inherit_attr), NULL, TRUE };
struct pseudo_console *pseudo_console;
+ HANDLE tty_input = NULL, tty_output;
HANDLE signal = NULL;
WCHAR pipe_name[64];
@@ -1751,9 +1752,15 @@ HRESULT WINAPI CreatePseudoConsole( COORD size, HANDLE input, HANDLE output, DWO
return HRESULT_FROM_WIN32( GetLastError() );
}
pseudo_console->signal = CreateFileW( pipe_name, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL );
- if (pseudo_console->signal != INVALID_HANDLE_VALUE)
- pseudo_console->reference = create_pseudo_console( size, input, output, signal, flags,
+ if (pseudo_console->signal != INVALID_HANDLE_VALUE &&
+ DuplicateHandle( GetCurrentProcess(), input, GetCurrentProcess(), &tty_input, 0, TRUE, DUPLICATE_SAME_ACCESS) &&
+ DuplicateHandle( GetCurrentProcess(), output, GetCurrentProcess(), &tty_output, 0, TRUE, DUPLICATE_SAME_ACCESS))
+ {
+ pseudo_console->reference = create_pseudo_console( size, tty_input, tty_output, signal, flags,
&pseudo_console->process );
+ NtClose( tty_output );
+ }
+ NtClose( tty_input );
NtClose( signal );
if (!pseudo_console->reference)
{
More information about the wine-cvs
mailing list