mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-03 08:08:43 +00:00
LibCore: Make singleton process helpers public
This commit is contained in:
parent
70149079e4
commit
12a9702acb
Notes:
sideshowbarker
2024-07-17 03:27:40 +09:00
Author: https://github.com/ADKaster
Commit: 12a9702acb
Pull-request: https://github.com/SerenityOS/serenity/pull/24126
Reviewed-by: https://github.com/trflynn89 ✅
2 changed files with 11 additions and 7 deletions
|
@ -379,7 +379,7 @@ ErrorOr<IPCProcess::ProcessAndIPCSocket> IPCProcess::spawn_and_connect_to_proces
|
|||
return ProcessAndIPCSocket { move(process), move(ipc_socket) };
|
||||
}
|
||||
|
||||
static ErrorOr<Optional<pid_t>> get_process_pid(StringView process_name, StringView pid_path)
|
||||
ErrorOr<Optional<pid_t>> 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<Optional<pid_t>> get_process_pid(StringView process_name, StringV
|
|||
}
|
||||
|
||||
// This is heavily based on how SystemServer's Service creates its socket.
|
||||
static ErrorOr<int> create_ipc_socket(ByteString const& socket_path)
|
||||
ErrorOr<int> 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<int> create_ipc_socket(ByteString const& socket_path)
|
|||
return socket_fd;
|
||||
}
|
||||
|
||||
struct ProcessPaths {
|
||||
ByteString socket_path;
|
||||
ByteString pid_path;
|
||||
};
|
||||
static ErrorOr<ProcessPaths> paths_for_process(StringView process_name)
|
||||
ErrorOr<IPCProcess::ProcessPaths> IPCProcess::paths_for_process(StringView process_name)
|
||||
{
|
||||
auto runtime_directory = TRY(StandardPaths::runtime_directory());
|
||||
auto socket_path = ByteString::formatted("{}/{}.socket", runtime_directory, process_name);
|
||||
|
|
|
@ -138,6 +138,14 @@ public:
|
|||
return ProcessAndIPCClient<ClientType> { move(process), move(client) };
|
||||
}
|
||||
|
||||
struct ProcessPaths {
|
||||
ByteString socket_path;
|
||||
ByteString pid_path;
|
||||
};
|
||||
static ErrorOr<ProcessPaths> paths_for_process(StringView process_name);
|
||||
static ErrorOr<Optional<pid_t>> get_process_pid(StringView process_name, StringView pid_path);
|
||||
static ErrorOr<int> create_ipc_socket(ByteString const& socket_path);
|
||||
|
||||
pid_t pid() const { return m_process.pid(); }
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue