[newlib-cygwin/cygwin-3_6-branch] Cygwin: pty: Clear discard_input flag on master write()

Takashi Yano via Cygwin-cvs <[email protected]> Wed, 25 Mar 2026 21:32:17 +0000 (GMT)
Newsgroups gmane.os.cygwin.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D020203c7c1a=
e3d482deb8c5d9625e368b90d3274

commit 020203c7c1ae3d482deb8c5d9625e368b90d3274
Author: Takashi Yano <[email protected]>
Date:   Fri Mar 20 02:37:48 2026 +0900

    Cygwin: pty: Clear discard_input flag on master write()
   =20
    Currently, the first transfer_input() after Ctrl-C does not work
    because discard_input flag remains asserted. This can cause loosing
    typeahead input for non-cygwin app after Ctrl-C. With this patch,
    the discard_input flag is cleared on master write() because the
    input is new valid input after discarding input.
   =20
    Fixes: 4e16e575db04 ("Cygwin: pty: Discard input already accepted on in=
terrupt.")
    Signed-off-by: Takashi Yano <[email protected]>
    Reviewed-by: Corinna Vinschen <[email protected]>
    (cherry picked from commit 50a87729d603cf7bf959f8cffc80371527a0537a)

Diff:
---
 winsup/cygwin/fhandler/pty.cc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/winsup/cygwin/fhandler/pty.cc b/winsup/cygwin/fhandler/pty.cc
index c900682da..a09c0debe 100644
--- a/winsup/cygwin/fhandler/pty.cc
+++ b/winsup/cygwin/fhandler/pty.cc
@@ -2132,6 +2132,8 @@ fhandler_pty_master::write (const void *ptr, size_t l=
en)
=20
   push_process_state process_state (PID_TTYOU);
=20
+  get_ttyp ()->discard_input =3D false;
+
   if (get_ttyp ()->pcon_start)
     { /* Reaches here when pseudo console initialization is on going. */
       /* Pseudo condole support uses "CSI6n" to get cursor position.