diff --git a/Ladybird/HelperProcess.cpp b/Ladybird/HelperProcess.cpp index 4d3c2c17d6a..624249be342 100644 --- a/Ladybird/HelperProcess.cpp +++ b/Ladybird/HelperProcess.cpp @@ -160,14 +160,7 @@ ErrorOr connect_new_request_server_client(Protocol::RequestClient& cl return Error::from_string_literal("Failed to connect to RequestServer"); auto socket = new_socket->take_client_socket(); - - // FIXME: IPC::Files transferred over the wire are always set O_CLOEXEC during decoding. - // Perhaps we should add an option to IPC::File to allow the receiver to decide whether to - // make it O_CLOEXEC or not. Or an attribute in the .ipc file? - auto fd = socket.fd(); - auto fd_flags = MUST(Core::System::fcntl(fd, F_GETFD)); - fd_flags &= ~FD_CLOEXEC; - MUST(Core::System::fcntl(fd, F_SETFD, fd_flags)); + TRY(socket.clear_close_on_exec()); return socket; } diff --git a/Userland/Libraries/LibIPC/File.h b/Userland/Libraries/LibIPC/File.h index ab565e7a400..338e740d8ba 100644 --- a/Userland/Libraries/LibIPC/File.h +++ b/Userland/Libraries/LibIPC/File.h @@ -63,6 +63,17 @@ public: return exchange(m_fd, -1); } + // FIXME: IPC::Files transferred over the wire are always set O_CLOEXEC during decoding. + // Perhaps we should add an option to IPC::File to allow the receiver to decide whether to + // make it O_CLOEXEC or not. Or an attribute in the .ipc file? + ErrorOr clear_close_on_exec() + { + auto fd_flags = TRY(Core::System::fcntl(m_fd, F_GETFD)); + fd_flags &= ~FD_CLOEXEC; + TRY(Core::System::fcntl(m_fd, F_SETFD, fd_flags)); + return {}; + } + private: explicit File(int fd) : m_fd(fd)