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.
This commit is contained in:
parent
5bb8d445f4
commit
d79aa0f593
|
@ -176,7 +176,7 @@ fhandler_fifo::create_pipe_instance (bool first)
|
||||||
access = GENERIC_READ | FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES
|
access = GENERIC_READ | FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES
|
||||||
| SYNCHRONIZE;
|
| SYNCHRONIZE;
|
||||||
sharing = FILE_SHARE_READ | FILE_SHARE_WRITE;
|
sharing = FILE_SHARE_READ | FILE_SHARE_WRITE;
|
||||||
hattr = OBJ_INHERIT;
|
hattr = openflags & O_CLOEXEC ? 0 : OBJ_INHERIT;
|
||||||
if (first)
|
if (first)
|
||||||
hattr |= OBJ_CASE_INSENSITIVE;
|
hattr |= OBJ_CASE_INSENSITIVE;
|
||||||
InitializeObjectAttributes (&attr, get_pipe_name (),
|
InitializeObjectAttributes (&attr, get_pipe_name (),
|
||||||
|
@ -209,7 +209,8 @@ fhandler_fifo::open_pipe (HANDLE& ph)
|
||||||
if (!NT_SUCCESS (status))
|
if (!NT_SUCCESS (status))
|
||||||
return status;
|
return status;
|
||||||
access = GENERIC_WRITE | SYNCHRONIZE;
|
access = GENERIC_WRITE | SYNCHRONIZE;
|
||||||
InitializeObjectAttributes (&attr, get_pipe_name (), OBJ_INHERIT,
|
InitializeObjectAttributes (&attr, get_pipe_name (),
|
||||||
|
openflags & O_CLOEXEC ? 0 : OBJ_INHERIT,
|
||||||
npfsh, NULL);
|
npfsh, NULL);
|
||||||
sharing = FILE_SHARE_READ | FILE_SHARE_WRITE;
|
sharing = FILE_SHARE_READ | FILE_SHARE_WRITE;
|
||||||
status = NtOpenFile (&ph, access, &attr, &io, sharing, 0);
|
status = NtOpenFile (&ph, access, &attr, &io, sharing, 0);
|
||||||
|
|
Loading…
Reference in New Issue