summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--winsup/cygwin/fhandler.cc6
1 files changed, 5 insertions, 1 deletions
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));