diff --git a/winsup/cygwin/fhandler/pty.cc b/winsup/cygwin/fhandler/pty.cc index 664d7dbc6..03c859172 100644 --- a/winsup/cygwin/fhandler/pty.cc +++ b/winsup/cygwin/fhandler/pty.cc @@ -3222,6 +3222,11 @@ fhandler_pty_slave::setup_pseudoconsole () 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; if (get_ttyp ()->pcon_activated) { /* The pseudo console is already activated. */ @@ -3499,6 +3504,7 @@ cleanup_pseudo_console: CloseHandle (tmp); } fallback: + get_ttyp ()->switch_to_nat_pipe = switch_to_nat_pipe_orig; return false; } diff --git a/winsup/cygwin/release/3.4.7 b/winsup/cygwin/release/3.4.7 index 2c305ec5f..941519ebc 100644 --- a/winsup/cygwin/release/3.4.7 +++ b/winsup/cygwin/release/3.4.7 @@ -9,3 +9,6 @@ Bug Fixes - Align behaviour of dirname in terms of leading slashes to POSIX: 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