Cygwin: pty: Fix reading CONIN$ when stdin is not a pty.

Previously, the pty master sends inputs to the pipe for cygwin app
even when pseudo console is activated if stdin is not the pty.
This causes the problem that key input is not sent to non cygwin
app even if the app opens CONIN$. This patch sets switch_to_nat_pipe
to true regardless whether stdin is the pty or not to allow that case.

https://cygwin.com/pipermail/cygwin/2023-April/253424.html

Reported-by: Wladislav Artsimovich <cygwin@frost.kiwi>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
This commit is contained in:
Takashi Yano 2023-04-14 10:52:08 +09:00
parent ef75abddc7
commit e5fcc5837c
2 changed files with 9 additions and 0 deletions

View File

@ -3222,6 +3222,11 @@ fhandler_pty_slave::setup_pseudoconsole ()
return false; return false;
} }
/* Set switch_to_nat_pipe regardless whether stdin is the pty or not
so that the non-cygwin app can work when it opens CONIN$. */
bool switch_to_nat_pipe_orig = get_ttyp ()->switch_to_nat_pipe;
get_ttyp ()->switch_to_nat_pipe = true;
HANDLE hpConIn, hpConOut; HANDLE hpConIn, hpConOut;
if (get_ttyp ()->pcon_activated) if (get_ttyp ()->pcon_activated)
{ /* The pseudo console is already activated. */ { /* The pseudo console is already activated. */
@ -3499,6 +3504,7 @@ cleanup_pseudo_console:
CloseHandle (tmp); CloseHandle (tmp);
} }
fallback: fallback:
get_ttyp ()->switch_to_nat_pipe = switch_to_nat_pipe_orig;
return false; return false;
} }

View File

@ -9,3 +9,6 @@ Bug Fixes
- Align behaviour of dirname in terms of leading slashes to POSIX: - Align behaviour of dirname in terms of leading slashes to POSIX:
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html
- Fix reading CONIN$ in non cygwin apps when stdin is not a pty.
Addresses https://cygwin.com/pipermail/cygwin/2023-April/253424.html