From 1066855532fe1172f15ab12898b74af2b38617ee Mon Sep 17 00:00:00 2001 From: Bananymous Date: Mon, 3 Jun 2024 18:01:34 +0300 Subject: [PATCH] LibGUI: Mark Window's server fd as CLOEXEC and expose it through API --- LibGUI/Window.cpp | 3 +++ LibGUI/include/LibGUI/Window.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/LibGUI/Window.cpp b/LibGUI/Window.cpp index 7305a617a5..4fdef8bd16 100644 --- a/LibGUI/Window.cpp +++ b/LibGUI/Window.cpp @@ -29,6 +29,9 @@ namespace LibGUI if (server_fd == -1) return BAN::Error::from_errno(errno); + if (fcntl(server_fd, F_SETFL, fcntl(server_fd, F_GETFL) | O_CLOEXEC) == -1) + return BAN::Error::from_errno(errno); + timespec start_time; clock_gettime(CLOCK_MONOTONIC, &start_time); diff --git a/LibGUI/include/LibGUI/Window.h b/LibGUI/include/LibGUI/Window.h index c88a4e2ebb..826b9d6ba5 100644 --- a/LibGUI/include/LibGUI/Window.h +++ b/LibGUI/include/LibGUI/Window.h @@ -133,6 +133,8 @@ namespace LibGUI void set_mouse_move_event_callback(BAN::Function callback) { m_mouse_move_event_callback = callback; } void set_mouse_scroll_event_callback(BAN::Function callback) { m_mouse_scroll_event_callback = callback; } + int server_fd() const { return m_server_fd; } + private: Window(int server_fd, uint32_t* framebuffer, uint32_t width, uint32_t height) : m_server_fd(server_fd)