diff options
author | Ken Brown <kbrown@cornell.edu> | 2019-05-28 15:50:05 -0400 |
---|---|---|
committer | Ken Brown <kbrown@cornell.edu> | 2019-05-28 15:50:05 -0400 |
commit | d79aa0f5939be2640b90971d022b98054b86d249 (patch) | |
tree | c56266d2b74951039b88811fe1f6e295c7349ccf | |
parent | 5bb8d445f480ee344e81326d8387da0c4ef009c8 (diff) | |
download | cygnal-d79aa0f5939be2640b90971d022b98054b86d249.tar.gz cygnal-d79aa0f5939be2640b90971d022b98054b86d249.tar.bz2 cygnal-d79aa0f5939be2640b90971d022b98054b86d249.zip |
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.
-rw-r--r-- | winsup/cygwin/fhandler_fifo.cc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/winsup/cygwin/fhandler_fifo.cc b/winsup/cygwin/fhandler_fifo.cc index 3fabbc3b4..c9ff0a309 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); |