[gnome-builder] libide/threading: work around lack of pipe2 on macOS



commit 7e925a96c1bc11a5b387779b53b2c3d51e5ba573
Author: Christian Hergert <christian hergert me>
Date:   Mon Jul 25 12:39:44 2022 -0700

    libide/threading: work around lack of pipe2 on macOS

 src/libide/threading/ide-unix-fd-map.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
---
diff --git a/src/libide/threading/ide-unix-fd-map.c b/src/libide/threading/ide-unix-fd-map.c
index 305604c15..e721347e6 100644
--- a/src/libide/threading/ide-unix-fd-map.c
+++ b/src/libide/threading/ide-unix-fd-map.c
@@ -422,6 +422,26 @@ ide_unix_fd_map_steal_from (IdeUnixFDMap  *self,
   return TRUE;
 }
 
+#ifdef __APPLE__
+static int
+pipe2 (int      fd_pair[2],
+       unsigned flags)
+{
+  int r = pipe (fd_pair);
+
+  if (r == -1)
+    return -1;
+
+  if (flags & O_CLOEXEC)
+    {
+      fcntl (fd_pair[0], F_SETFD, FD_CLOEXEC);
+      fcntl (fd_pair[1], F_SETFD, FD_CLOEXEC);
+    }
+
+  return r;
+}
+#endif
+
 /**
  * ide_unix_fd_map_create_stream:
  * @self: a #IdeUnixFdMap


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]