From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7868) id 495953858D20; Fri, 14 Apr 2023 03:37:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 495953858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681443444; bh=pQuov2RBAj3VKU3waTZj6T1U8eYWig95569CMxnlz58=; h=From:To:Subject:Date:From; b=skAAvUfzFzeR+AGi4Th56pD/818kdXwatxHNqfhn2qffFln2ErlreYSUfdh0MUHMt eVl9D20XcWHu+aTgpZBdDBOY7iUKaC2hoQpZP2ePRexLzbetOPCjVYLBBmgCvbWffw Wkus77SWToA7Jl5KaobMUxm9+MxfVmf9Wq8ftgAg= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Takashi Yano To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/cygwin-3_4-branch] Cygwin: pty: Fix reading CONIN$ when stdin is not a pty. X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/cygwin-3_4-branch X-Git-Oldrev: 2bc5e1f6f35bbafd5de62d532d6a77b6292bed8a X-Git-Newrev: 595fcb21ffc01b3469dad6484c11ebfd263d7f3c Message-Id: <20230414033724.495953858D20@sourceware.org> Date: Fri, 14 Apr 2023 03:37:24 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D595fcb21ffc= 01b3469dad6484c11ebfd263d7f3c commit 595fcb21ffc01b3469dad6484c11ebfd263d7f3c Author: Takashi Yano Date: Fri Apr 14 10:52:08 2023 +0900 Cygwin: pty: Fix reading CONIN$ when stdin is not a pty. =20 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. =20 https://cygwin.com/pipermail/cygwin/2023-April/253424.html =20 Reported-by: Wladislav Artsimovich Signed-off-by: Takashi Yano Diff: --- winsup/cygwin/fhandler/pty.cc | 6 ++++++ winsup/cygwin/release/3.4.7 | 3 +++ 2 files changed, 9 insertions(+) diff --git a/winsup/cygwin/fhandler/pty.cc b/winsup/cygwin/fhandler/pty.cc index e9a379b1c..aa7ceb0ba 100644 --- a/winsup/cygwin/fhandler/pty.cc +++ b/winsup/cygwin/fhandler/pty.cc @@ -3274,6 +3274,11 @@ fhandler_pty_slave::setup_pseudoconsole () return false; } =20 + /* 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 =3D get_ttyp ()->switch_to_nat_pipe; + get_ttyp ()->switch_to_nat_pipe =3D true; + HANDLE hpConIn, hpConOut; if (get_ttyp ()->pcon_activated) { /* The pseudo console is already activated. */ @@ -3551,6 +3556,7 @@ cleanup_pseudo_console: CloseHandle (tmp); } fallback: + get_ttyp ()->switch_to_nat_pipe =3D switch_to_nat_pipe_orig; return false; } =20 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 =20 - 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