]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
adaint.c (_gnat_set_close_on_exec): Implement.
authorAaron W. LaFramboise <aaronavay62@aaronwl.com>
Sun, 17 Aug 2008 05:44:15 +0000 (23:44 -0600)
committerAaron W. LaFramboise <aaronwl@gcc.gnu.org>
Sun, 17 Aug 2008 05:44:15 +0000 (23:44 -0600)
2008-08-17  Aaron W. LaFramboise  <aaronavay62@aaronwl.com>

* adaint.c (_gnat_set_close_on_exec) [_WIN32]: Implement.

From-SVN: r139167

gcc/ada/ChangeLog
gcc/ada/adaint.c

index a5169b7a3594d94be1c85f0f8db3a5240a94dc5f..8aa238fc285a81248acea73ef9408394b48b2218 100644 (file)
@@ -1,3 +1,7 @@
+2008-08-17  Aaron W. LaFramboise  <aaronavay62@aaronwl.com>
+
+       * adaint.c (_gnat_set_close_on_exec) [_WIN32]: Implement.
+
 2008-08-16  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interface/trans.c (call_to_gnu): Use the Sloc of the call
index b7fdd08d2526e21e07f51dc838004a6ee874c253..48abb3e5049e66eeddf7c3c8072c1bf02ac29c64 100644 (file)
@@ -3248,12 +3248,17 @@ __gnat_set_close_on_exec (int fd ATTRIBUTE_UNUSED,
   else
     flags &= ~FD_CLOEXEC;
   return fcntl (fd, F_SETFD, flags | FD_CLOEXEC);
+#elif defined(_WIN32)
+  HANDLE h = (HANDLE) _get_osfhandle (fd);
+  if (h == (HANDLE) -1)
+    return -1;
+  if (close_on_exec_p)
+    return ! SetHandleInformation (h, HANDLE_FLAG_INHERIT, 0);
+  return ! SetHandleInformation (h, HANDLE_FLAG_INHERIT, 
+    HANDLE_FLAG_INHERIT);
 #else
+  /* TODO: Unimplemented. */
   return -1;
-  /* For the Windows case, we should use SetHandleInformation to remove
-     the HANDLE_INHERIT property from fd. This is not implemented yet,
-     but for our purposes (support of GNAT.Expect) this does not matter,
-     as by default handles are *not* inherited. */
 #endif
 }