public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] setup_pseudoconsole(): handle missing/incorrect helper gracefully Date: Mon, 4 May 2020 09:21:21 +0000 (GMT) [thread overview] Message-ID: <20200504092121.A7F79383E832@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=717db9fd1ce369d5279480613bcf61daf658309a commit 717db9fd1ce369d5279480613bcf61daf658309a Author: Johannes Schindelin <Johannes.Schindelin@gmx.de> Date: Sat May 2 15:03:07 2020 +0200 setup_pseudoconsole(): handle missing/incorrect helper gracefully 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> Diff: --- 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 */
reply other threads:[~2020-05-04 9:21 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200504092121.A7F79383E832@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).