From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7868) id 5EC903858423; Sun, 13 Feb 2022 15:18:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5EC903858423 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-3_3-branch] Cygwin: console: Set console mode even if stdin/stdout is redirected. X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/cygwin-3_3-branch X-Git-Oldrev: 37d2888745f124ad3c468df3878995446b2a6c5e X-Git-Newrev: 6b676704090110efe653bb465eef00c59a565ba2 Message-Id: <20220213151820.5EC903858423@sourceware.org> Date: Sun, 13 Feb 2022 15:18:20 +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: Sun, 13 Feb 2022 15:18:20 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D6b676704090= 110efe653bb465eef00c59a565ba2 commit 6b676704090110efe653bb465eef00c59a565ba2 Author: Takashi Yano Date: Sun Feb 13 17:11:02 2022 +0900 Cygwin: console: Set console mode even if stdin/stdout is redirected. =20 - When non-cygwin app is started in console, console mode is set to tty::native. However, if stdin is redirected, current code does not set the input mode of the console. In this case, if the app opens "CONIN$", the console mode will not be appropriate for non-cygwin app. This patch fixes the issue. =20 Addresses: https://github.com/GitCredentialManager/git-credential-manager/issues/5= 76 Diff: --- winsup/cygwin/spawn.cc | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 81dba5a94..a7e25cc20 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -627,23 +627,18 @@ child_info_spawn::worker (const char *prog_arg, const= char *const *argv, } else if (fh && fh->get_major () =3D=3D DEV_CONS_MAJOR) { - fhandler_console *cons =3D (fhandler_console *) fh; - if (!iscygwin ()) + if (!iscygwin () && cons_native =3D=3D NULL) { - if (cons_native =3D=3D NULL) - { - cons_native =3D cons; - cons_ti =3D &((tty *)cons->tc ())->ti; - cons_owner =3D cons->get_owner (); - } + fhandler_console *cons =3D (fhandler_console *) fh; + cons_native =3D cons; + cons_ti =3D &((tty *)cons->tc ())->ti; + cons_owner =3D cons->get_owner (); tty::cons_mode conmode =3D (ctty_pgid && ctty_pgid =3D=3D myself->pgid) ? tty::native : tty::restore; - if (fd =3D=3D 0) - fhandler_console::set_input_mode (conmode, + fhandler_console::set_input_mode (conmode, cons_ti, cons->get_handle_set ()); - else if (fd =3D=3D 1 || fd =3D=3D 2) - fhandler_console::set_output_mode (conmode, + fhandler_console::set_output_mode (conmode, cons_ti, cons->get_handle_set ()); } }