[PATCH] dlls/kernelbase, programs/conhost: don't delay the TTY input thread for PE executables
Eric Pouech
eric.pouech at gmail.com
Mon Dec 6 08:59:54 CST 2021
currently, conhost delays the start of the input thread until the first
console read operation
some PE executables (like mingw's gdb port) just do something like:
- WaitForSingleObject(GetStdHandle(STD_INPUT_HANDLE), INFINITE) and hang
for ever (the read operations are done *after* the wait operation
succeeds)
(of course, the real wait operation is more complex, but the problematic
part boils down to that)
I understand that the delay has been introduced so that executables still
reading directly from the unix fd will continue to work.
But I could miss some other use cases.
This patch forces the start the tty input thread in conhost if current
executable is a PE executable.
This lets mingw's gdb work a bit further (at least allowing some user input
<g>) under wine. (x86_64 seems to be quite ok, i686 still needs come
cudling)
Signed-off-by: Eric Pouech <eric.pouech at gmail.com>
---
dlls/kernelbase/console.c | 8 ++++++--
programs/conhost/conhost.c | 9 +++++++--
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/dlls/kernelbase/console.c b/dlls/kernelbase/console.c
index a7eeb439232..b6f2c4fb394 100644
--- a/dlls/kernelbase/console.c
+++ b/dlls/kernelbase/console.c
@@ -1694,8 +1694,12 @@ static HANDLE create_pseudo_console( COORD size, HANDLE input, HANDLE output, HA
}
else
{
- swprintf( cmd, ARRAY_SIZE(cmd), L"\"%s\" --unix --width %u --height %u --server 0x%x",
- conhost_path, size.X, size.Y, server );
+ LDR_DATA_TABLE_ENTRY *ldr;
+ const WCHAR* start_thread = L"";
+ if (LdrFindEntryForAddress( GetModuleHandleW( NULL) , &ldr ) == STATUS_SUCCESS &&
+ !(ldr->Flags & LDR_WINE_INTERNAL)) start_thread = L"--thread ";
+ swprintf( cmd, ARRAY_SIZE(cmd), L"\"%s\" --unix %s--width %u --height %u --server 0x%x",
+ conhost_path, start_thread, size.X, size.Y, server );
}
Wow64DisableWow64FsRedirection( &redir );
res = CreateProcessW( conhost_path, cmd, NULL, NULL, TRUE, DETACHED_PROCESS, NULL, NULL,
diff --git a/programs/conhost/conhost.c b/programs/conhost/conhost.c
index 05447d52dd5..27788fbd6a8 100644
--- a/programs/conhost/conhost.c
+++ b/programs/conhost/conhost.c
@@ -2736,7 +2736,7 @@ static int main_loop( struct console *console, HANDLE signal )
int __cdecl wmain(int argc, WCHAR *argv[])
{
- int headless = 0, i, width = 0, height = 0;
+ int headless = 0, i, width = 0, height = 0, start_thread = 0;
HANDLE signal = NULL;
WCHAR *end;
@@ -2765,6 +2765,11 @@ int __cdecl wmain(int argc, WCHAR *argv[])
headless = 1;
continue;
}
+ if (!wcscmp( argv[i], L"--thread"))
+ {
+ start_thread = 1;
+ continue;
+ }
if (!wcscmp( argv[i], L"--width" ))
{
if (++i == argc) return 1;
@@ -2812,7 +2817,7 @@ int __cdecl wmain(int argc, WCHAR *argv[])
console.tty_input = GetStdHandle( STD_INPUT_HANDLE );
console.tty_output = GetStdHandle( STD_OUTPUT_HANDLE );
init_tty_output( &console );
- if (!console.is_unix && !ensure_tty_input_thread( &console )) return 1;
+ if ((!console.is_unix || start_thread) && !ensure_tty_input_thread( &console )) return 1;
}
else
{
More information about the wine-devel
mailing list