1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:54:58 +00:00

LibCore: Use Core::Stream for ProcessStatisticsReader

This commit is contained in:
Tim Schumacher 2022-12-08 14:50:31 +01:00 committed by Linus Groh
parent e338a0656d
commit 8940f2da7f
18 changed files with 55 additions and 95 deletions

View file

@ -141,11 +141,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
outln("{:28} {:>4} {:>4} {:10} {:>4} {}", "COMMAND", "PID", "PGID", "USER", "FD", "NAME");
auto all_processes = Core::ProcessStatisticsReader::get_all();
if (!all_processes.has_value())
return 1;
auto all_processes = TRY(Core::ProcessStatisticsReader::get_all());
if (arg_pid == -1) {
for (auto& process : all_processes.value().processes) {
for (auto& process : all_processes.processes) {
if (process.pid == 0)
continue;
auto open_files = get_open_files_by_pid(process.pid);
@ -170,7 +168,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return 0;
for (auto& file : open_files) {
display_entry(file, *all_processes->processes.find_if([&](auto& entry) { return entry.pid == arg_pid; }));
display_entry(file, *all_processes.processes.find_if([&](auto& entry) { return entry.pid == arg_pid; }));
}
}