gdb/
[binutils-gdb.git] / libiberty / pex-win32.c
index 91e0bc882ff1275217ae5bc898d64b95a6d31b79..44274067482c772ce21115b730d46747040e1492 100644 (file)
@@ -915,6 +915,11 @@ static FILE *
 pex_win32_fdopenr (struct pex_obj *obj ATTRIBUTE_UNUSED, int fd,
                   int binary)
 {
+  HANDLE h = (HANDLE) _get_osfhandle (fd);
+  if (h == INVALID_HANDLE_VALUE)
+    return NULL;
+  if (! SetHandleInformation (h, HANDLE_FLAG_INHERIT, 0))
+    return NULL;
   return fdopen (fd, binary ? "rb" : "r");
 }