public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: FIFO: respect the O_CLOEXEC flag
@ 2019-05-28 20:15 Ken Brown
  0 siblings, 0 replies; only message in thread
From: Ken Brown @ 2019-05-28 20:15 UTC (permalink / raw)
  To: cygwin-cvs

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

commit d79aa0f5939be2640b90971d022b98054b86d249
Author: Ken Brown <kbrown@cornell.edu>
Date:   Tue May 28 15:50:05 2019 -0400

    Cygwin: FIFO: respect the O_CLOEXEC flag
    
    Set the inheritance of the Windows pipe handles according to the
    O_CLOEXEC flag.  Previously the pipe was always created and opened
    with OBJ_INHERIT.

Diff:
---
 winsup/cygwin/fhandler_fifo.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/fhandler_fifo.cc b/winsup/cygwin/fhandler_fifo.cc
index 3fabbc3..c9ff0a3 100644
--- a/winsup/cygwin/fhandler_fifo.cc
+++ b/winsup/cygwin/fhandler_fifo.cc
@@ -176,7 +176,7 @@ fhandler_fifo::create_pipe_instance (bool first)
   access = GENERIC_READ | FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES
     | SYNCHRONIZE;
   sharing = FILE_SHARE_READ | FILE_SHARE_WRITE;
-  hattr = OBJ_INHERIT;
+  hattr = openflags & O_CLOEXEC ? 0 : OBJ_INHERIT;
   if (first)
     hattr |= OBJ_CASE_INSENSITIVE;
   InitializeObjectAttributes (&attr, get_pipe_name (),
@@ -209,7 +209,8 @@ fhandler_fifo::open_pipe (HANDLE& ph)
   if (!NT_SUCCESS (status))
     return status;
   access = GENERIC_WRITE | SYNCHRONIZE;
-  InitializeObjectAttributes (&attr, get_pipe_name (), OBJ_INHERIT,
+  InitializeObjectAttributes (&attr, get_pipe_name (),
+			      openflags & O_CLOEXEC ? 0 : OBJ_INHERIT,
 			      npfsh, NULL);
   sharing = FILE_SHARE_READ | FILE_SHARE_WRITE;
   status = NtOpenFile (&ph, access, &attr, &io, sharing, 0);


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

only message in thread, other threads:[~2019-05-28 20:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-28 20:15 [newlib-cygwin] Cygwin: FIFO: respect the O_CLOEXEC flag Ken Brown

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).