From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7868) id D13E53858016; Sun, 13 Feb 2022 15:19:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D13E53858016 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: Set console mode even if stdin/stdout is redirected. X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/master X-Git-Oldrev: cb0e392903aeb4f2abe0fd06319e484d0a22938c X-Git-Newrev: dd653423157b49ebe0c07f692cf8ba483b76e8b7 Message-Id: <20220213151904.D13E53858016@sourceware.org> Date: Sun, 13 Feb 2022 15:19:04 +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:19:04 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Ddd653423157= b49ebe0c07f692cf8ba483b76e8b7 commit dd653423157b49ebe0c07f692cf8ba483b76e8b7 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 ()); } }