public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
From: Takashi Yano <takashi.yano@nifty.ne.jp>
To: cygwin-patches@cygwin.com
Subject: [PATCH] Cygwin: pty: Omit transfer_input() call where it is no longer needed.
Date: Fri,  4 Mar 2022 20:05:56 +0900	[thread overview]
Message-ID: <20220304110556.2139-3-takashi.yano@nifty.ne.jp> (raw)
In-Reply-To: <20220304110556.2139-1-takashi.yano@nifty.ne.jp>

- This patch removes the old code which calls transfer_input() but
  is no longer needed. These code was necessary indeed in the past,
  however, as a result of recent frequent code changes, it is no
  longer needed.
---
 winsup/cygwin/fhandler_tty.cc | 47 -----------------------------------
 1 file changed, 47 deletions(-)

diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 76c5e2413..a0a5a70ba 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -1216,56 +1216,9 @@ fhandler_pty_slave::reset_switch_to_nat_pipe (void)
       && process_alive (get_ttyp ()->nat_pipe_owner_pid))
     {
       /* There is a process which owns nat pipe. */
-      if (!to_be_read_from_nat_pipe ()
-	  && get_ttyp ()->pty_input_state_eq (tty::to_nat))
-	{
-	  if (get_ttyp ()->pcon_activated)
-	    {
-	      HANDLE pcon_owner = OpenProcess (PROCESS_DUP_HANDLE, FALSE,
-					   get_ttyp ()->nat_pipe_owner_pid);
-	      if (pcon_owner)
-		{
-		  HANDLE h_pcon_in;
-		  DuplicateHandle (pcon_owner, get_ttyp ()->h_pcon_in,
-				   GetCurrentProcess (), &h_pcon_in,
-				   0, TRUE, DUPLICATE_SAME_ACCESS);
-		  DWORD target_pid = get_ttyp ()->nat_pipe_owner_pid;
-		  DWORD resume_pid = attach_console_temporarily (target_pid);
-		  WaitForSingleObject (input_mutex, mutex_timeout);
-		  transfer_input (tty::to_cyg, h_pcon_in, get_ttyp (),
-				  input_available_event);
-		  ReleaseMutex (input_mutex);
-		  resume_from_temporarily_attach (resume_pid);
-		  CloseHandle (h_pcon_in);
-		  CloseHandle (pcon_owner);
-		}
-	    }
-	  else if (!get_ttyp ()->nat_fg (get_ttyp ()->getpgid ())
-		   && get_ttyp ()->switch_to_nat_pipe)
-	    {
-	      WaitForSingleObject (input_mutex, mutex_timeout);
-	      acquire_attach_mutex (mutex_timeout);
-	      transfer_input (tty::to_cyg, get_handle_nat (), get_ttyp (),
-			      input_available_event);
-	      release_attach_mutex ();
-	      ReleaseMutex (input_mutex);
-	    }
-	}
       ReleaseMutex (pipe_sw_mutex);
       return;
     }
-  /* This input transfer is needed if non-cygwin app is terminated
-     by Ctrl-C or killed. */
-  WaitForSingleObject (input_mutex, mutex_timeout);
-  if (get_ttyp ()->switch_to_nat_pipe && !get_ttyp ()->pcon_activated
-      && get_ttyp ()->pty_input_state_eq (tty::to_nat))
-    {
-      acquire_attach_mutex (mutex_timeout);
-      transfer_input (tty::to_cyg, get_handle_nat (), get_ttyp (),
-		      input_available_event);
-      release_attach_mutex ();
-    }
-  ReleaseMutex (input_mutex);
   /* Clean up nat pipe state */
   get_ttyp ()->pty_input_state = tty::to_cyg;
   get_ttyp ()->nat_pipe_owner_pid = 0;
-- 
2.35.1


      parent reply	other threads:[~2022-03-04 11:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-04 11:05 [PATCH] Cygwin: pty: Treat both CR and NL as line feed in transfer_inpup() Takashi Yano
2022-03-04 11:05 ` [PATCH] Cygwin: pty: Rearrange reset_switch_to_nat_pipe() calls Takashi Yano
2022-03-04 11:05 ` Takashi Yano [this message]

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=20220304110556.2139-3-takashi.yano@nifty.ne.jp \
    --to=takashi.yano@nifty.ne.jp \
    --cc=cygwin-patches@cygwin.com \
    /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).