From 12a9702acb0a858e8a50813fb891f2774c790840 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Fri, 26 Apr 2024 15:18:36 -0600 Subject: [PATCH] LibCore: Make singleton process helpers public --- Userland/Libraries/LibCore/Process.cpp | 10 +++------- Userland/Libraries/LibCore/Process.h | 8 ++++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Userland/Libraries/LibCore/Process.cpp b/Userland/Libraries/LibCore/Process.cpp index 3935750a25b..bf0e1bbe28a 100644 --- a/Userland/Libraries/LibCore/Process.cpp +++ b/Userland/Libraries/LibCore/Process.cpp @@ -379,7 +379,7 @@ ErrorOr IPCProcess::spawn_and_connect_to_proces return ProcessAndIPCSocket { move(process), move(ipc_socket) }; } -static ErrorOr> get_process_pid(StringView process_name, StringView pid_path) +ErrorOr> IPCProcess::get_process_pid(StringView process_name, StringView pid_path) { if (System::stat(pid_path).is_error()) return OptionalNone {}; @@ -416,7 +416,7 @@ static ErrorOr> get_process_pid(StringView process_name, StringV } // This is heavily based on how SystemServer's Service creates its socket. -static ErrorOr create_ipc_socket(ByteString const& socket_path) +ErrorOr IPCProcess::create_ipc_socket(ByteString const& socket_path) { if (!System::stat(socket_path).is_error()) TRY(System::unlink(socket_path)); @@ -444,11 +444,7 @@ static ErrorOr create_ipc_socket(ByteString const& socket_path) return socket_fd; } -struct ProcessPaths { - ByteString socket_path; - ByteString pid_path; -}; -static ErrorOr paths_for_process(StringView process_name) +ErrorOr IPCProcess::paths_for_process(StringView process_name) { auto runtime_directory = TRY(StandardPaths::runtime_directory()); auto socket_path = ByteString::formatted("{}/{}.socket", runtime_directory, process_name); diff --git a/Userland/Libraries/LibCore/Process.h b/Userland/Libraries/LibCore/Process.h index 18c7b918097..a870b97be78 100644 --- a/Userland/Libraries/LibCore/Process.h +++ b/Userland/Libraries/LibCore/Process.h @@ -138,6 +138,14 @@ public: return ProcessAndIPCClient { move(process), move(client) }; } + struct ProcessPaths { + ByteString socket_path; + ByteString pid_path; + }; + static ErrorOr paths_for_process(StringView process_name); + static ErrorOr> get_process_pid(StringView process_name, StringView pid_path); + static ErrorOr create_ipc_socket(ByteString const& socket_path); + pid_t pid() const { return m_process.pid(); } private: