From a57ad3e77a5b4760fc161406c411cd9d5084c39a Mon Sep 17 00:00:00 2001 From: Takashi Yano Date: Thu, 16 Sep 2021 20:50:54 +0900 Subject: [PATCH 1/3] 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. --- 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); -- 2.33.0