Kernel+LibCore: Add process creation time to /sys/kernel/processes

This commit is contained in:
Tim Ledbetter 2023-06-09 17:22:07 +01:00 committed by Andreas Kling
parent 4d49852454
commit f95dccdb45
3 changed files with 4 additions and 0 deletions

View file

@ -83,6 +83,7 @@ ErrorOr<void> SysFSOverallProcesses::try_generate(KBufferBuilder& builder)
}
TRY(process.name().with([&](auto& process_name) { return process_object.add("name"sv, process_name->view()); }));
TRY(process_object.add("executable"sv, process.executable() ? TRY(process.executable()->try_serialize_absolute_path())->view() : ""sv));
TRY(process_object.add("creation_time"sv, process.creation_time().nanoseconds_since_epoch()));
size_t amount_virtual = 0;
size_t amount_resident = 0;

View file

@ -42,6 +42,7 @@ ErrorOr<AllProcessesStatistics> ProcessStatisticsReader::get_all(SeekableStream&
process.tty = process_object.get_deprecated_string("tty"sv).value_or("");
process.pledge = process_object.get_deprecated_string("pledge"sv).value_or("");
process.veil = process_object.get_deprecated_string("veil"sv).value_or("");
process.creation_time = UnixDateTime::from_nanoseconds_since_epoch(process_object.get_i64("creation_time"sv).value_or(0));
process.amount_virtual = process_object.get_u32("amount_virtual"sv).value_or(0);
process.amount_resident = process_object.get_u32("amount_resident"sv).value_or(0);
process.amount_shared = process_object.get_u32("amount_shared"sv).value_or(0);

View file

@ -7,6 +7,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/Time.h>
#include <AK/Vector.h>
#include <unistd.h>
@ -49,6 +50,7 @@ struct ProcessStatistics {
DeprecatedString tty;
DeprecatedString pledge;
DeprecatedString veil;
UnixDateTime creation_time;
size_t amount_virtual;
size_t amount_resident;
size_t amount_shared;