From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7868) id 38CE1385801B; Thu, 3 Mar 2022 18:19:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 38CE1385801B 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: pty: Simplify the setup code for GDB a bit. X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/master X-Git-Oldrev: d6b778617d3d3869971579427dd45648a2e75030 X-Git-Newrev: efd153853c44876cceb430a0cc1a1a94e2067c96 Message-Id: <20220303181945.38CE1385801B@sourceware.org> Date: Thu, 3 Mar 2022 18:19:45 +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, 03 Mar 2022 18:19:45 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Defd153853c4= 4876cceb430a0cc1a1a94e2067c96 commit efd153853c44876cceb430a0cc1a1a94e2067c96 Author: Takashi Yano Date: Thu Mar 3 10:55:12 2022 +0900 Cygwin: pty: Simplify the setup code for GDB a bit. =20 - This patch omits the unnecessary code path for setup for GDB. Diff: --- winsup/cygwin/fhandler_tty.cc | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index be3e6fcba..c7588a073 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -121,12 +121,12 @@ static bool isHybrid; /* Set true if the active pipe = is set to nat pipe even static HANDLE h_gdb_inferior; /* Handle of GDB inferior process. */ =20 static void -set_switch_to_nat_pipe (HANDLE *in, HANDLE *out, HANDLE *err, bool iscygwi= n) +set_switch_to_nat_pipe (HANDLE *in, HANDLE *out, HANDLE *err) { cygheap_fdenum cfd (false); int fd; fhandler_base *replace_in =3D NULL, *replace_out =3D NULL, *replace_err = =3D NULL; - fhandler_pty_slave *ptys_nat =3D NULL; + fhandler_pty_slave *ptys =3D NULL; while ((fd =3D cfd.next ()) >=3D 0) { if (*in =3D=3D cfd->get_handle () || @@ -141,15 +141,14 @@ set_switch_to_nat_pipe (HANDLE *in, HANDLE *out, HAND= LE *err, bool iscygwin) if (cfd->get_device () =3D=3D (dev_t) myself->ctty) { fhandler_base *fh =3D cfd; - fhandler_pty_slave *ptys =3D (fhandler_pty_slave *) fh; - if (*in =3D=3D ptys->get_handle () - || *out =3D=3D ptys->get_output_handle () - || *err =3D=3D ptys->get_output_handle ()) - ptys_nat =3D ptys; + if (*in =3D=3D fh->get_handle () + || *out =3D=3D fh->get_output_handle () + || *err =3D=3D fh->get_output_handle ()) + ptys =3D (fhandler_pty_slave *) fh; } } - if (!iscygwin && ptys_nat) - ptys_nat->set_switch_to_nat_pipe (); + if (ptys) + ptys->set_switch_to_nat_pipe (); if (replace_in) *in =3D replace_in->get_handle_nat (); if (replace_out) @@ -280,8 +279,9 @@ CreateProcessA_Hooked siov->hStdError =3D GetStdHandle (STD_ERROR_HANDLE); } bool path_iscygexec =3D fhandler_termios::path_iscygexec_a (n, c); - set_switch_to_nat_pipe (&siov->hStdInput, &siov->hStdOutput, - &siov->hStdError, path_iscygexec); + if (!path_iscygexec) + set_switch_to_nat_pipe (&siov->hStdInput, &siov->hStdOutput, + &siov->hStdError); BOOL ret =3D CreateProcessA_Orig (n, c, pa, ta, inh, f, e, d, siov, pi); h_gdb_inferior =3D pi->hProcess; DuplicateHandle (GetCurrentProcess (), h_gdb_inferior, @@ -318,8 +318,9 @@ CreateProcessW_Hooked siov->hStdError =3D GetStdHandle (STD_ERROR_HANDLE); } bool path_iscygexec =3D fhandler_termios::path_iscygexec_w (n, c); - set_switch_to_nat_pipe (&siov->hStdInput, &siov->hStdOutput, - &siov->hStdError, path_iscygexec); + if (!path_iscygexec) + set_switch_to_nat_pipe (&siov->hStdInput, &siov->hStdOutput, + &siov->hStdError); BOOL ret =3D CreateProcessW_Orig (n, c, pa, ta, inh, f, e, d, siov, pi); h_gdb_inferior =3D pi->hProcess; DuplicateHandle (GetCurrentProcess (), h_gdb_inferior,