[newlib-cygwin] Cygwin: pty: Fix cursor position on new nat app in existing pcon
Takashi Yano
tyan0@sourceware.org
Mon Aug 3 02:46:05 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=9e2f67d8b4ad7f229dc0e8d3e74f00a07ec0952e
commit 9e2f67d8b4ad7f229dc0e8d3e74f00a07ec0952e
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date: Tue Jul 21 04:59:09 2026 +0900
Cygwin: pty: Fix cursor position on new nat app in existing pcon
Previously, the steps: cmd.exe -> bash -> cmd.exe exhibit broken
cursor position even with the commit b34394d456b6 ("Cygwin: pty:
Fixup pty state after a cygwin app exits").
This patch sets req_fixup_pcon_cur_pos also when reusing existing
pseudo console as well as req_xfer_input. In addition, clearing
`pcon_start_pid` has been moved inside `input_mutex`, to addess
the race condition that becomes harmfull with this patch.
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Reviewed-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Diff:
---
winsup/cygwin/fhandler/pty.cc | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/winsup/cygwin/fhandler/pty.cc b/winsup/cygwin/fhandler/pty.cc
index f3df55f34..6d8f6d5c1 100644
--- a/winsup/cygwin/fhandler/pty.cc
+++ b/winsup/cygwin/fhandler/pty.cc
@@ -2671,8 +2671,8 @@ fhandler_pty_master::write (const void *ptr, size_t len)
release_attach_mutex ();
}
get_ttyp ()->req_xfer_input = false;
- ReleaseMutex (input_mutex);
get_ttyp ()->pcon_start_pid = 0;
+ ReleaseMutex (input_mutex);
}
if (len == 0)
return orig_len;
@@ -3850,6 +3850,7 @@ fhandler_pty_slave::setup_pseudoconsole ()
WaitForSingleObject (input_mutex, mutex_timeout);
get_ttyp ()->req_xfer_input = true; /* indicates that this "ESC[6n"
is just for transfer input */
+ get_ttyp ()->req_fixup_pcon_cur_pos = true;
get_ttyp ()->pcon_start = true;
get_ttyp ()->pcon_start_pid = myself->pid;
WriteFile (get_output_handle (), "\033[6n", 4, &n, NULL);
More information about the Cygwin-cvs
mailing list