From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2210) id EAA98385843C; Thu, 16 Sep 2021 15:41:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EAA98385843C Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Ken Brown To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: close_all_files: Do not duplicate stderr for write pipe. X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/master X-Git-Oldrev: 18fab2f834cce4f0494610cc3085c5a1c6649635 X-Git-Newrev: 350806f8825985d3a16b18c6f41476415f9dd7cf Message-Id: <20210916154104.EAA98385843C@sourceware.org> Date: Thu, 16 Sep 2021 15:41:04 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Sep 2021 15:41:05 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=350806f8825985d3a16b18c6f41476415f9dd7cf commit 350806f8825985d3a16b18c6f41476415f9dd7cf Author: Takashi Yano Date: Thu Sep 16 20:50:54 2021 +0900 Cygwin: close_all_files: Do not duplicate stderr for write pipe. - Currently, the stderr handle is duplicated in close_all_files(). This interferes the handle counting for detecting closure of read pipe, which is introduced by commit f79a4611. This patch stops duplicating stderr handle if it is write pipe. Diff: --- winsup/cygwin/syscalls.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 11af079cb..a3ffe3532 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -95,7 +95,7 @@ close_all_files (bool norelease) if (cfd >= 0) { debug_only_printf ("closing fd %d", i); - if (i == 2) + if (i == 2 && cfd->get_dev () != FH_PIPEW) DuplicateHandle (GetCurrentProcess (), cfd->get_output_handle (), GetCurrentProcess (), &h, 0, false, DUPLICATE_SAME_ACCESS);