From b9387ecbf4ee6435728db5902dbdb188d74850b3 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Fri, 31 Jul 2026 14:33:59 +0000 Subject: [PATCH] ui: provide a pipe2 replacement for Darwin pipe2(2) is Linux/BSD-only; Darwin has no way to create a pipe with O_CLOEXEC atomically. The only caller is the Wayland drag-and-drop receive path, where nothing can exec between pipe() and fcntl(), so a plain non-atomic emulation is fully equivalent there. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01G6m1eevhAns3j85HMZYKna --- src/ui_wayland.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/ui_wayland.cpp b/src/ui_wayland.cpp index 5005587..21f0087 100644 --- src/ui_wayland.cpp +++ src/ui_wayland.cpp @@ -17,6 +17,21 @@ #include #include +#ifdef __APPLE__ +// Darwin has no pipe2(). Emulate the O_CLOEXEC part; the window +// between pipe() and fcntl() is benign here, nothing execs +// concurrently with the drag-and-drop receive path. +static int pipe2(int fds[2], int /* flags */) +{ + if (pipe(fds) == -1) { + return -1; + } + fcntl(fds[0], F_SETFD, FD_CLOEXEC); + fcntl(fds[1], F_SETFD, FD_CLOEXEC); + return 0; +} +#endif + // MIME type for drag-and-drop of raw path static constexpr const char* MIME_TEXT_PLAIN = "text/plain";