public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Takashi Yano <tyan0@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/cygwin-3_3-branch] Cygwin: console: Fix interference issue regarding master thread. Date: Thu, 18 Nov 2021 10:20:55 +0000 (GMT) [thread overview] Message-ID: <20211118102055.5DA963858406@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=f9f06a4607adb9dfcc4fbf88ed2ba0653943677d commit f9f06a4607adb9dfcc4fbf88ed2ba0653943677d Author: Takashi Yano <takashi.yano@nifty.ne.jp> Date: Thu Nov 18 12:28:53 2021 +0900 Cygwin: console: Fix interference issue regarding master thread. - This patch fixes the issue that ReadConsoleInputW() call in the master thread interferes with the input process of non-cygwin apps. Diff: --- winsup/cygwin/fhandler.h | 1 + winsup/cygwin/fhandler_console.cc | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index c033f7816..f9baff852 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -2042,6 +2042,7 @@ class dev_console char cons_rabuf[40]; // cannot get longer than char buf[40] in char_command char *cons_rapoi; bool cursor_key_app_mode; + bool disable_master_thread; inline UINT get_console_cp (); DWORD con_to_str (char *d, int dlen, WCHAR w); diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index a7e9723bd..4b7922dea 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -208,6 +208,12 @@ fhandler_console::cons_master_thread (handle_set_t *p, tty *ttyp) DWORD total_read, n, i; INPUT_RECORD input_rec[INREC_SIZE]; + if (con.disable_master_thread) + { + cygwait (40); + continue; + } + WaitForSingleObject (p->input_mutex, INFINITE); total_read = 0; switch (cygwait (p->input_handle, (DWORD) 0)) @@ -427,6 +433,7 @@ fhandler_console::setup () con.cons_rapoi = NULL; shared_console_info->tty_min_state.is_console = true; con.cursor_key_app_mode = false; + con.disable_master_thread = false; } } @@ -480,6 +487,8 @@ fhandler_console::set_input_mode (tty::cons_mode m, const termios *t, flags |= ENABLE_VIRTUAL_TERMINAL_INPUT; else flags |= ENABLE_MOUSE_INPUT; + if (shared_console_info) + con.disable_master_thread = false; break; case tty::native: if (t->c_lflag & ECHO) @@ -492,6 +501,8 @@ fhandler_console::set_input_mode (tty::cons_mode m, const termios *t, flags &= ~ENABLE_ECHO_INPUT; if (t->c_lflag & ISIG) flags |= ENABLE_PROCESSED_INPUT; + if (shared_console_info) + con.disable_master_thread = true; break; } SetConsoleMode (p->input_handle, flags);
reply other threads:[~2021-11-18 10:20 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=20211118102055.5DA963858406@sourceware.org \ --to=tyan0@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).