public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin] Cygwin: pty: Fix state mismatch caused in mintty.
Date: Mon, 10 Feb 2020 10:04:00 -0000	[thread overview]
Message-ID: <20200210100455.119961.qmail@sourceware.org> (raw)

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

commit 2de74af22be0ccf75f094caf48c8beb36a49d8c9
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date:   Sun Feb 9 23:47:30 2020 +0900

    Cygwin: pty: Fix state mismatch caused in mintty.
    
    - PTY has a bug reported in:
      https://cygwin.com/ml/cygwin/2020-02/msg00067.html.
      This is the result of state mismatch between real pseudo console
      attaching state and state variable. This patch fixes the issue.

Diff:
---
 winsup/cygwin/fhandler_tty.cc | 16 ++++++++++++++--
 winsup/cygwin/fork.cc         |  2 ++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index f2fd680..260776a 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -65,6 +65,12 @@ static bool isHybrid;
 static bool do_not_reset_switch_to_pcon;
 static bool freeconsole_on_close = true;
 
+void
+clear_pcon_attached_to (void)
+{
+  pcon_attached_to = -1;
+}
+
 static void
 set_switch_to_pcon (void)
 {
@@ -727,7 +733,10 @@ fhandler_pty_slave::~fhandler_pty_slave ()
 	{
 	  init_console_handler (false);
 	  if (freeconsole_on_close)
-	    FreeConsole ();
+	    {
+	      FreeConsole ();
+	      pcon_attached_to = -1;
+	    }
 	}
     }
 }
@@ -2988,7 +2997,10 @@ fhandler_pty_slave::fixup_after_exec ()
 	{
 	  init_console_handler (false);
 	  if (freeconsole_on_close)
-	    FreeConsole ();
+	    {
+	      FreeConsole ();
+	      pcon_attached_to = -1;
+	    }
 	}
     }
 
diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc
index a8f0fb8..691d081 100644
--- a/winsup/cygwin/fork.cc
+++ b/winsup/cygwin/fork.cc
@@ -161,6 +161,8 @@ frok::child (volatile char * volatile here)
 	      }
 	  }
       }
+  extern void clear_pcon_attached_to (void); /* fhandler_tty.cc */
+  clear_pcon_attached_to ();
 
   HANDLE& hParent = ch.parent;


                 reply	other threads:[~2020-02-10 10:04 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=20200210100455.119961.qmail@sourceware.org \
    --to=corinna@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).