From 0c8ca1736ee07c7d7dbce05108120cf4f8937bd0 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Thu, 4 Jun 2020 10:15:38 +0200
Subject: [PATCH] fcntl: do not call GetHandleInformation() in Winstore apps

The API is forbidden [1] and HANDLE_FLAG_INHERIT would never be set as exec()
is not allowed either [2].

[1] https://docs.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-gethandleinformation
[2] https://docs.microsoft.com/en-us/cpp/cppcx/crt-functions-not-supported-in-universal-windows-platform-apps
---
 gl/fcntl.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/gl/fcntl.c b/gl/fcntl.c
index 6b9927ec4..e316ca306 100644
--- a/gl/fcntl.c
+++ b/gl/fcntl.c
@@ -229,12 +229,19 @@ fcntl (int fd, int action, /* arg */...)
       {
 # if defined _WIN32 && ! defined __CYGWIN__
         HANDLE handle = (HANDLE) _get_osfhandle (fd);
+#  if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
         DWORD flags;
         if (handle == INVALID_HANDLE_VALUE
             || GetHandleInformation (handle, &flags) == 0)
           errno = EBADF;
         else
           result = (flags & HANDLE_FLAG_INHERIT) ? 0 : FD_CLOEXEC;
+#  else /* ! WINAPI_PARTITION_DESKTOP */
+        if (handle == INVALID_HANDLE_VALUE)
+          errno = EBADF;
+        else
+          result = 0;
+#  endif /* ! WINAPI_PARTITION_DESKTOP */
 # else /* !W32 */
         /* Use dup2 to reject invalid file descriptors.  No way to
            access this information, so punt.  */
--
2.26.0.windows.1

