[newlib-cygwin] Cygwin: fix inheritence of select_sem on write side of pipe

Corinna Vinschen corinna@sourceware.org
Tue Sep 14 15:07:49 GMT 2021


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=c48361ad9e84a3b8217111c03eda5d7820eebb2e

commit c48361ad9e84a3b8217111c03eda5d7820eebb2e
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Mon Sep 13 19:33:56 2021 +0200

    Cygwin: fix inheritence of select_sem on write side of pipe
    
    select_sem gets created on the read side with inheritence settings
    depending on the O_CLOEXEC flag.  Then it gets duplicated to the write
    side with unconditional inheritence.  Fix that.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/fhandler_pipe.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/winsup/cygwin/fhandler_pipe.cc b/winsup/cygwin/fhandler_pipe.cc
index 9b4255cfd..62cb1c0ec 100644
--- a/winsup/cygwin/fhandler_pipe.cc
+++ b/winsup/cygwin/fhandler_pipe.cc
@@ -790,7 +790,7 @@ fhandler_pipe::create (fhandler_pipe *fhs[2], unsigned psize, int mode)
       if (fhs[0]->select_sem)
 	DuplicateHandle (GetCurrentProcess (), fhs[0]->select_sem,
 			 GetCurrentProcess (), &fhs[1]->select_sem,
-			 0, 1, DUPLICATE_SAME_ACCESS);
+			 0, !(mode & O_CLOEXEC), DUPLICATE_SAME_ACCESS);
     }
 
   debug_printf ("%R = pipe([%p, %p], %d, %y)", res, fhs[0], fhs[1], psize, mode);


More information about the Cygwin-cvs mailing list