From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7868) id CE3E53858C50; Tue, 13 Feb 2024 14:38:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE3E53858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1707835080; bh=oOKDcp6FPzmO+KKa94ctpyUgFS4iE0wCQHIjWW71XMI=; h=From:To:Subject:Date:From; b=WKIi79jpmrxs2/F2bnovGHW2Xp0RT16DActZej9TG11D3kO+Yud94bV/g5fQEgLoX NGeqgkhMHgP1LBPuEVeOJ1IlypAGGTfYncQGOxxx7r69iFtnpdBQMV0G0itYyXJmN7 rConKW1eYrsYzXsh0jYp0/o8MEa4WlzFAVczsg4w= 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: pty: Fix handle leak in master process. X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/master X-Git-Oldrev: 10c8c1cf4f94ed42c59015d7e972269724c451bf X-Git-Newrev: 06992ed6b4c63c6e77052fdc9359ce003fc3409f Message-Id: <20240213143800.CE3E53858C50@sourceware.org> Date: Tue, 13 Feb 2024 14:38:00 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D06992ed6b4c= 63c6e77052fdc9359ce003fc3409f commit 06992ed6b4c63c6e77052fdc9359ce003fc3409f Author: Takashi Yano Date: Tue Feb 13 11:17:46 2024 +0900 Cygwin: pty: Fix handle leak in master process. =20 If non-cygwin process is started in pty, closing from_master_nat pipe handle was missing in fhandler_pty_slave::input_transfer(). This occured because the handle was duplicated but not closed. =20 https://github.com/msys2/msys2-runtime/issues/198 =20 Fixes: 29431fcb5b14 ("Cygwin: pty: Inherit typeahead data between two i= nput pipes.") Reported-by: Hakkin Lain Signed-off-by: Takashi Yano Diff: --- winsup/cygwin/fhandler/pty.cc | 1 + winsup/cygwin/release/3.5.1 | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/winsup/cygwin/fhandler/pty.cc b/winsup/cygwin/fhandler/pty.cc index 3f4bc56b5..c5c792144 100644 --- a/winsup/cygwin/fhandler/pty.cc +++ b/winsup/cygwin/fhandler/pty.cc @@ -3995,6 +3995,7 @@ fhandler_pty_slave::transfer_input (tty::xfer_dir dir= , HANDLE from, tty *ttyp, transfered =3D true;; } } + CloseHandle (to); =20 /* Fix input_available_event which indicates availability in cyg pipe. */ if (dir =3D=3D tty::to_nat) /* all data is transfered to nat pipe, diff --git a/winsup/cygwin/release/3.5.1 b/winsup/cygwin/release/3.5.1 index 81945dbda..715fcf74d 100644 --- a/winsup/cygwin/release/3.5.1 +++ b/winsup/cygwin/release/3.5.1 @@ -12,3 +12,7 @@ Fixes: error mode is now possible by using the new CYGWIN environment variable option "winjitdebug". Addresses: https://cygwin.com/pipermail/cygwin/2024-February/255305.html + +- Fix handle leak in pty master which occurs when non-cygwin process + is started in pty. + Addresses: https://github.com/msys2/msys2-runtime/issues/198