https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=0c545f3264aaaac3d02d3ef785a2e2e9d77ed03f
commit 0c545f3264aaaac3d02d3ef785a2e2e9d77ed03f Author: Corinna Vinschen <cori...@vinschen.de> Date: Tue Jan 8 18:50:11 2019 +0100 Cygwin: open: handle O_CLOEXEC when opening file from handle Signed-off-by: Corinna Vinschen <cori...@vinschen.de> Diff: --- winsup/cygwin/fhandler.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index 9f5e009..9af08d7 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -555,7 +555,11 @@ fhandler_base::open (int flags, mode_t mode) /* Allow to reopen from handle. This is utilized by open ("/proc/PID/fd/DESCRIPTOR", ...); */ if (get_handle ()) - pc.init_reopen_attr (attr, get_handle ()); + { + pc.init_reopen_attr (attr, get_handle ()); + if (!(flags & O_CLOEXEC)) + attr.Attributes |= OBJ_INHERIT; + } else pc.get_object_attr (attr, *sec_none_cloexec (flags));