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: pty: Simplify the setup code for GDB a bit.
Date: Thu,  3 Mar 2022 18:19:45 +0000 (GMT)	[thread overview]
Message-ID: <20220303181945.38CE1385801B@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=efd153853c44876cceb430a0cc1a1a94e2067c96

commit efd153853c44876cceb430a0cc1a1a94e2067c96
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date:   Thu Mar 3 10:55:12 2022 +0900

    Cygwin: pty: Simplify the setup code for GDB a bit.
    
    - 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. */
 
 static void
-set_switch_to_nat_pipe (HANDLE *in, HANDLE *out, HANDLE *err, bool iscygwin)
+set_switch_to_nat_pipe (HANDLE *in, HANDLE *out, HANDLE *err)
 {
   cygheap_fdenum cfd (false);
   int fd;
   fhandler_base *replace_in = NULL, *replace_out = NULL, *replace_err = NULL;
-  fhandler_pty_slave *ptys_nat = NULL;
+  fhandler_pty_slave *ptys = NULL;
   while ((fd = cfd.next ()) >= 0)
     {
       if (*in == cfd->get_handle () ||
@@ -141,15 +141,14 @@ set_switch_to_nat_pipe (HANDLE *in, HANDLE *out, HANDLE *err, bool iscygwin)
       if (cfd->get_device () == (dev_t) myself->ctty)
 	{
 	  fhandler_base *fh = cfd;
-	  fhandler_pty_slave *ptys = (fhandler_pty_slave *) fh;
-	  if (*in == ptys->get_handle ()
-	      || *out == ptys->get_output_handle ()
-	      || *err == ptys->get_output_handle ())
-	    ptys_nat = ptys;
+	  if (*in == fh->get_handle ()
+	      || *out == fh->get_output_handle ()
+	      || *err == fh->get_output_handle ())
+	    ptys = (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 = replace_in->get_handle_nat ();
   if (replace_out)
@@ -280,8 +279,9 @@ CreateProcessA_Hooked
       siov->hStdError = GetStdHandle (STD_ERROR_HANDLE);
     }
   bool path_iscygexec = 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 = CreateProcessA_Orig (n, c, pa, ta, inh, f, e, d, siov, pi);
   h_gdb_inferior = pi->hProcess;
   DuplicateHandle (GetCurrentProcess (), h_gdb_inferior,
@@ -318,8 +318,9 @@ CreateProcessW_Hooked
       siov->hStdError = GetStdHandle (STD_ERROR_HANDLE);
     }
   bool path_iscygexec = 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 = CreateProcessW_Orig (n, c, pa, ta, inh, f, e, d, siov, pi);
   h_gdb_inferior = pi->hProcess;
   DuplicateHandle (GetCurrentProcess (), h_gdb_inferior,


                 reply	other threads:[~2022-03-03 18:19 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=20220303181945.38CE1385801B@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: link
Be 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).