public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: pipe, fifo: Call set_no_inheritance() for adjunct handles.
@ 2021-09-14 15:08 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2021-09-14 15:08 UTC (permalink / raw)
  To: cygwin-cvs

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

commit 0d12015670a00b7ecb2db4f66368e863b68de13d
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date:   Tue Sep 14 12:49:35 2021 +0900

    Cygwin: pipe, fifo: Call set_no_inheritance() for adjunct handles.
    
    - Currntly, set_no_inheritance() is not called for the adjunct handles
      such as select_sem. This patch fixes the issue.

Diff:
---
 winsup/cygwin/fhandler.h       |  1 +
 winsup/cygwin/fhandler_fifo.cc |  2 ++
 winsup/cygwin/fhandler_pipe.cc | 10 ++++++++++
 3 files changed, 13 insertions(+)

diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 13fba9a14..46381c397 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -1208,6 +1208,7 @@ public:
   void open_setup (int flags);
   void fixup_after_fork (HANDLE);
   int dup (fhandler_base *child, int);
+  void set_close_on_exec (bool val);
   int close ();
   void __reg3 raw_read (void *ptr, size_t& len);
   int ioctl (unsigned int cmd, void *);
diff --git a/winsup/cygwin/fhandler_fifo.cc b/winsup/cygwin/fhandler_fifo.cc
index aa89fa7ae..37498f547 100644
--- a/winsup/cygwin/fhandler_fifo.cc
+++ b/winsup/cygwin/fhandler_fifo.cc
@@ -1817,4 +1817,6 @@ fhandler_fifo::set_close_on_exec (bool val)
 	set_no_inheritance (fc_handler[i].h, val);
       fifo_client_unlock ();
     }
+  if (select_sem)
+    set_no_inheritance (select_sem, val);
 }
diff --git a/winsup/cygwin/fhandler_pipe.cc b/winsup/cygwin/fhandler_pipe.cc
index 70cfa3784..da473a1dc 100644
--- a/winsup/cygwin/fhandler_pipe.cc
+++ b/winsup/cygwin/fhandler_pipe.cc
@@ -515,6 +515,16 @@ fhandler_pipe_fifo::raw_write (const void *ptr, size_t len)
   return nbytes ?: -1;
 }
 
+void
+fhandler_pipe::set_close_on_exec (bool val)
+{
+  fhandler_base::set_close_on_exec (val);
+  if (read_mtx)
+    set_no_inheritance (read_mtx, val);
+  if (select_sem)
+    set_no_inheritance (select_sem, val);
+}
+
 void
 fhandler_pipe::fixup_after_fork (HANDLE parent)
 {


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-14 15:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-14 15:08 [newlib-cygwin] Cygwin: pipe, fifo: Call set_no_inheritance() for adjunct handles Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).