From 0c545f3264aaaac3d02d3ef785a2e2e9d77ed03f Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Tue, 8 Jan 2019 18:50:11 +0100 Subject: [PATCH] Cygwin: open: handle O_CLOEXEC when opening file from handle Signed-off-by: Corinna Vinschen --- 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 9f5e0094f..9af08d735 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));