From b9f1c7084bcea173fda0bdd5095a53ecbe718947 Mon Sep 17 00:00:00 2001 From: R-Goc Date: Thu, 4 Dec 2025 21:41:24 +0100 Subject: [PATCH] LibIPC: Add missing include and impl on win32 This commit adds a missing include to MessageWindows after header cleanup. It also implement IPC::File which had its implementation moved out of the header, without the matching change to the windows implementation. --- Libraries/LibIPC/FileWindows.cpp | 49 +++++++++++++++++++++++++++++ Libraries/LibIPC/MessageWindows.cpp | 1 + 2 files changed, 50 insertions(+) diff --git a/Libraries/LibIPC/FileWindows.cpp b/Libraries/LibIPC/FileWindows.cpp index dfc7be512de..bbeba2a44d6 100644 --- a/Libraries/LibIPC/FileWindows.cpp +++ b/Libraries/LibIPC/FileWindows.cpp @@ -4,6 +4,8 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include +#include #include #include #include @@ -12,6 +14,53 @@ namespace IPC { +File File::adopt_file(NonnullOwnPtr file) +{ + return File(file->leak_fd()); +} + +File File::adopt_fd(int fd) +{ + return File(fd); +} + +ErrorOr File::clone_fd(int fd) +{ + int new_fd = TRY(Core::System::dup(fd)); + return File(new_fd); +} + +File::File(int fd) + : m_fd(fd) +{ +} + +File::File(File&& other) + : m_fd(exchange(other.m_fd, -1)) +{ +} + +File& File::operator=(File&& other) +{ + if (this != &other) { + m_fd = exchange(other.m_fd, -1); + } + return *this; +} + +File::~File() +{ + if (m_fd != -1) + (void)Core::System::close(m_fd); +} + +// FIXME: IPC::Files transferred over the wire always set O_CLOEXEC during decoding. Perhaps we should add an option to +// allow the receiver to decide whether to make it O_CLOEXEC or not. Or an attribute in the .ipc file? +ErrorOr File::clear_close_on_exec() +{ + return Core::System::set_close_on_exec(m_fd, false); +} + template<> ErrorOr decode(Decoder& decoder) { diff --git a/Libraries/LibIPC/MessageWindows.cpp b/Libraries/LibIPC/MessageWindows.cpp index c5be237c534..4d8487bb2ca 100644 --- a/Libraries/LibIPC/MessageWindows.cpp +++ b/Libraries/LibIPC/MessageWindows.cpp @@ -6,6 +6,7 @@ */ #include +#include #include #include