From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7868) id 714F33857002; Thu, 28 Jul 2022 15:17:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 714F33857002 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Takashi Yano To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: console: Add workaround for ConEmu cygwin connector. X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/master X-Git-Oldrev: d4aacd50e6cfd3188a29c04fc04c126e367c33e8 X-Git-Newrev: f2e39d5230bb73258604446acb84d01ef503268d Message-Id: <20220728151747.714F33857002@sourceware.org> Date: Thu, 28 Jul 2022 15:17:47 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jul 2022 15:17:47 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Df2e39d5230b= b73258604446acb84d01ef503268d commit f2e39d5230bb73258604446acb84d01ef503268d Author: Takashi Yano Date: Thu Jul 28 21:58:04 2022 +0900 Cygwin: console: Add workaround for ConEmu cygwin connector. =20 - ConEmu cygwin connector conflicts with cons_master_thread since it does not use read() to read console input. With this patch, cons_master_thread is disabled in ConEmu cygwin connector. Diff: --- winsup/cygwin/fhandler_console.cc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_con= sole.cc index c20239d13..37262f638 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -1604,6 +1604,8 @@ fhandler_console::dup (fhandler_base *child, int flag= s) return 0; } =20 +static void hook_conemu_cygwin_connector(); + int fhandler_console::open (int flags, mode_t) { @@ -1691,6 +1693,8 @@ fhandler_console::open (int flags, mode_t) =20 if (myself->pid =3D=3D con.owner) { + if (GetModuleHandle ("ConEmuHk64.dll")) + hook_conemu_cygwin_connector (); char name[MAX_PATH]; shared_name (name, CONS_THREAD_SYNC, get_minor ()); thread_sync_event =3D CreateEvent(NULL, FALSE, FALSE, name); @@ -3982,6 +3986,7 @@ fhandler_console::set_console_mode_to_native () DEF_HOOK (CreateProcessA); DEF_HOOK (CreateProcessW); DEF_HOOK (ContinueDebugEvent); +DEF_HOOK (LoadLibraryA); /* Hooked for ConEmu cygwin connector */ =20 static BOOL WINAPI CreateProcessA_Hooked @@ -4023,6 +4028,20 @@ ContinueDebugEvent_Hooked return ContinueDebugEvent_Orig (p, t, s); } =20 +/* Hooked for ConEmu cygwin connector */ +static HMODULE WINAPI +LoadLibraryA_Hooked (LPCSTR m) +{ + const char *p; + if ((p =3D strrchr(m, '\\'))) + p++; + else + p =3D m; + if (strcasecmp(p, "ConEmuHk64.dll") =3D=3D 0) + fhandler_console::set_disable_master_thread (true); + return LoadLibraryA_Orig (m); +} + void fhandler_console::fixup_after_fork_exec (bool execing) { @@ -4046,6 +4065,12 @@ fhandler_console::fixup_after_fork_exec (bool execin= g) DO_HOOK (NULL, ContinueDebugEvent); } =20 +static void +hook_conemu_cygwin_connector() +{ + DO_HOOK (NULL, LoadLibraryA); +} + /* Ugly workaround to create invisible console required since Windows 7. =20 First try to just attach to any console which may have started this