From 6261c433a3db311714e61a009e88e4e7d524bab8 Mon Sep 17 00:00:00 2001 From: ayeteadoe Date: Sat, 23 Aug 2025 23:47:03 -0700 Subject: [PATCH] LibWebView: Implement stubbed out BrowserProcess methods on Windows --- Libraries/LibWebView/BrowserProcess.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Libraries/LibWebView/BrowserProcess.cpp b/Libraries/LibWebView/BrowserProcess.cpp index caac026008f..ca1f44760cd 100644 --- a/Libraries/LibWebView/BrowserProcess.cpp +++ b/Libraries/LibWebView/BrowserProcess.cpp @@ -45,9 +45,8 @@ ErrorOr BrowserProcess::connect(Vector BrowserProcess::connect_as_client([[maybe_unused]] ByteString const& socket_path, [[maybe_unused]] Vector const& raw_urls, [[maybe_unused]] NewWindow new_window) +ErrorOr BrowserProcess::connect_as_client(ByteString const& socket_path, Vector const& raw_urls, NewWindow new_window) { -#if !defined(AK_OS_WINDOWS) // TODO: Mach IPC auto socket = TRY(Core::LocalSocket::connect(socket_path)); auto client = UIProcessClient::construct(make(move(socket))); @@ -61,14 +60,10 @@ ErrorOr BrowserProcess::connect_as_client([[maybe_unused]] ByteString cons } return {}; -#else - return Error::from_string_literal("BrowserProcess::connect_as_client() is not implemented on Windows"); -#endif } -ErrorOr BrowserProcess::connect_as_server([[maybe_unused]] ByteString const& socket_path) +ErrorOr BrowserProcess::connect_as_server(ByteString const& socket_path) { -#if !defined(AK_OS_WINDOWS) // TODO: Mach IPC auto socket_fd = TRY(Process::create_ipc_socket(socket_path)); m_socket_path = socket_path; @@ -90,15 +85,18 @@ ErrorOr BrowserProcess::connect_as_server([[maybe_unused]] ByteString cons }; return {}; -#else - return Error::from_string_literal("BrowserProcess::connect_as_server() is not implemented on Windows"); -#endif } BrowserProcess::~BrowserProcess() { if (m_pid_file) { MUST(m_pid_file->truncate(0)); +#if defined(AK_OS_WINDOWS) + // NOTE: On Windows, System::open() duplicates the underlying OS file handle, + // so we need to explicitly close said handle, otherwise the unlink() call fails due + // to permission errors and we crash on shutdown. + m_pid_file->close(); +#endif MUST(Core::System::unlink(m_pid_path)); }