* [PATCH] setup_pseudoconsole(): handle missing/incorrect helper gracefully
@ 2020-05-02 13:03 Johannes Schindelin
2020-05-04 9:27 ` Corinna Vinschen
0 siblings, 1 reply; 2+ messages in thread
From: Johannes Schindelin @ 2020-05-02 13:03 UTC (permalink / raw)
To: cygwin-patches
When `cygwin-console-helper.exe` is either missing, or corresponds to a
different Cygwin runtime, we currently wait forever while setting up
access to the pseudo console, even long after the process is gone that
was supposed to signal that it set up access to the pseudo console.
Let's handle that more gracefully: if the process exited without
signaling, we cannot use the pseudo console. In that case, let's just
fall back to not using it.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
It took me three days to bisect why my test build of the MSYS2
runtime hung MinTTY. Three complete days.
The reason? I missed that `cygwin-console-helper.exe` needs to be
copied into the test environment, too, not just the DLL.
In hindsight, it would have been smarter to just attach to the
hanging process, but then, I thought if MinTTY is hanging, then
surely GDB will hang, too.
winsup/cygwin/fhandler_tty.cc | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index b2e725d5d..8547ec7c4 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -3496,7 +3496,23 @@ fhandler_pty_master::setup_pseudoconsole ()
TRUE, EXTENDED_STARTUPINFO_PRESENT,
NULL, NULL, &si_helper.StartupInfo, &pi_helper))
goto cleanup_event_and_pipes;
- WaitForSingleObject (hello, INFINITE);
+ for (;;)
+ {
+ DWORD wait_result = WaitForSingleObject (hello, 500);
+ if (wait_result == WAIT_OBJECT_0)
+ break;
+ if (wait_result != WAIT_TIMEOUT)
+ goto cleanup_helper_process;
+ DWORD exit_code;
+ if (!GetExitCodeProcess(pi_helper.hProcess, &exit_code))
+ goto cleanup_helper_process;
+ if (exit_code == STILL_ACTIVE)
+ continue;
+ if (exit_code != 0 ||
+ WaitForSingleObject (hello, 500) != WAIT_OBJECT_0)
+ goto cleanup_helper_process;
+ break;
+ }
CloseHandle (hello);
CloseHandle (pi_helper.hThread);
/* Retrieve pseudo console handles */
--
2.26.1.windows.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] setup_pseudoconsole(): handle missing/incorrect helper gracefully
2020-05-02 13:03 [PATCH] setup_pseudoconsole(): handle missing/incorrect helper gracefully Johannes Schindelin
@ 2020-05-04 9:27 ` Corinna Vinschen
0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2020-05-04 9:27 UTC (permalink / raw)
To: cygwin-patches
On May 2 15:03, Johannes Schindelin wrote:
> When `cygwin-console-helper.exe` is either missing, or corresponds to a
> different Cygwin runtime, we currently wait forever while setting up
> access to the pseudo console, even long after the process is gone that
> was supposed to signal that it set up access to the pseudo console.
>
> Let's handle that more gracefully: if the process exited without
> signaling, we cannot use the pseudo console. In that case, let's just
> fall back to not using it.
Pushed.
Thanks,
Corinna
--
Corinna Vinschen
Cygwin Maintainer
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-04 9:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-02 13:03 [PATCH] setup_pseudoconsole(): handle missing/incorrect helper gracefully Johannes Schindelin
2020-05-04 9:27 ` Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).