[newlib-cygwin] Cygwin: pty: Do not switch input to to_nat if native app is background
Takashi Yano
tyan0@sourceware.org
Thu Mar 5 23:32:55 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=db6269c2aee5f797cb8e2c71ac902e50acd29b20
commit db6269c2aee5f797cb8e2c71ac902e50acd29b20
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date: Tue Mar 3 22:00:56 2026 +0900
Cygwin: pty: Do not switch input to to_nat if native app is background
If the native (non-cygwin) app is started as background process,
the input should be kept in to_cyg mode because input data should
go to the cygwin shell that start the non-cygwin app. However,
currently it is switched to to_nat mode in a short time and reverted
to to_cyg mode just after that.
With this patch, to avoid this behaviour, switching to to_nat mode
is inhibited by checking PGID of the process, that is newly created
for a background process and differs from PGID of the tty.
Fixes: Fixes: 9fc746d17dc3 ("Cygwin: pty: Fix transferring type-ahead input between input pipes.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Reviewed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Diff:
---
winsup/cygwin/fhandler/pty.cc | 1 +
1 file changed, 1 insertion(+)
diff --git a/winsup/cygwin/fhandler/pty.cc b/winsup/cygwin/fhandler/pty.cc
index b59f54096..59396c4a7 100644
--- a/winsup/cygwin/fhandler/pty.cc
+++ b/winsup/cygwin/fhandler/pty.cc
@@ -2204,6 +2204,7 @@ fhandler_pty_master::write (const void *ptr, size_t len)
{ /* Pseudo console initialization has been done in above code. */
pinfo pp (get_ttyp ()->pcon_start_pid);
if (get_ttyp ()->switch_to_nat_pipe
+ && pp && pp->pgid == get_ttyp ()->getpgid ()
&& get_ttyp ()->pty_input_state_eq (tty::to_cyg))
{
/* This accept_input() call is needed in order to transfer input
More information about the Cygwin-cvs
mailing list