mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:27:35 +00:00
LibCore: Use Core::Stream
for ProcessStatisticsReader
This commit is contained in:
parent
e338a0656d
commit
8940f2da7f
18 changed files with 55 additions and 95 deletions
|
@ -1073,15 +1073,13 @@ ErrorOr<Optional<DeprecatedString>> Window::compute_title_username(ConnectionFro
|
|||
{
|
||||
if (!client)
|
||||
return Error::from_string_literal("Tried to compute title username without a client");
|
||||
auto stats = Core::ProcessStatisticsReader::get_all(true);
|
||||
if (!stats.has_value())
|
||||
return Error::from_string_literal("Failed to get all process statistics");
|
||||
auto stats = TRY(Core::ProcessStatisticsReader::get_all(true));
|
||||
pid_t client_pid = TRY(client->socket().peer_pid());
|
||||
auto client_stat = stats.value().processes.first_matching([&](auto& stat) { return stat.pid == client_pid; });
|
||||
auto client_stat = stats.processes.first_matching([&](auto& stat) { return stat.pid == client_pid; });
|
||||
if (!client_stat.has_value())
|
||||
return Error::from_string_literal("Failed to find client process stat");
|
||||
pid_t login_session_pid = TRY(Core::SessionManagement::root_session_id(client_pid));
|
||||
auto login_session_stat = stats.value().processes.first_matching([&](auto& stat) { return stat.pid == login_session_pid; });
|
||||
auto login_session_stat = stats.processes.first_matching([&](auto& stat) { return stat.pid == login_session_pid; });
|
||||
if (!login_session_stat.has_value())
|
||||
return Error::from_string_literal("Failed to find login process stat");
|
||||
if (login_session_stat.value().uid == client_stat.value().uid)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue