Kernel: Use try_serialize_absolute_path in ProcFSOverallProcesses
This commit is contained in:
parent
4e7d307166
commit
eb5f6cd108
Notes:
sideshowbarker
2024-07-17 21:03:54 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/eb5f6cd1088 Pull-request: https://github.com/SerenityOS/serenity/pull/11817 Reviewed-by: https://github.com/bgianfo ✅
1 changed files with 9 additions and 6 deletions
|
@ -453,7 +453,7 @@ private:
|
|||
JsonObjectSerializer<KBufferBuilder> json { builder };
|
||||
|
||||
// Keep this in sync with CProcessStatistics.
|
||||
auto build_process = [&](JsonArraySerializer<KBufferBuilder>& array, const Process& process) {
|
||||
auto build_process = [&](JsonArraySerializer<KBufferBuilder>& array, const Process& process) -> ErrorOr<void> {
|
||||
auto process_object = array.add_object();
|
||||
|
||||
if (process.is_user_process()) {
|
||||
|
@ -493,7 +493,7 @@ private:
|
|||
process_object.add("ppid", process.ppid().value());
|
||||
process_object.add("nfds", process.fds().open_count());
|
||||
process_object.add("name", process.name());
|
||||
process_object.add("executable", process.executable() ? process.executable()->absolute_path() : "");
|
||||
process_object.add("executable", process.executable() ? TRY(process.executable()->try_serialize_absolute_path())->view() : ""sv);
|
||||
process_object.add("tty", process.tty() ? process.tty()->tty_name().view() : "notty"sv);
|
||||
process_object.add("amount_virtual", process.address_space().amount_virtual());
|
||||
process_object.add("amount_resident", process.address_space().amount_resident());
|
||||
|
@ -530,17 +530,20 @@ private:
|
|||
thread_object.add("ipv4_socket_read_bytes", thread.ipv4_socket_read_bytes());
|
||||
thread_object.add("ipv4_socket_write_bytes", thread.ipv4_socket_write_bytes());
|
||||
});
|
||||
|
||||
return {};
|
||||
};
|
||||
|
||||
SpinlockLocker lock(g_scheduler_lock);
|
||||
{
|
||||
{
|
||||
auto array = json.add_array("processes");
|
||||
build_process(array, *Scheduler::colonel());
|
||||
Process::all_instances().with([&](auto& processes) {
|
||||
TRY(build_process(array, *Scheduler::colonel()));
|
||||
TRY(Process::all_instances().with([&](auto& processes) -> ErrorOr<void> {
|
||||
for (auto& process : processes)
|
||||
build_process(array, process);
|
||||
});
|
||||
TRY(build_process(array, process));
|
||||
return {};
|
||||
}));
|
||||
}
|
||||
|
||||
auto total_time_scheduled = Scheduler::get_total_time_scheduled();
|
||||
|
|
Loading…
Add table
Reference in a new issue