mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-03 00:42:54 +00:00
LibCore: Report error condition when reading process statistics failed
This commit is contained in:
parent
754bf22da7
commit
cf89180c35
Notes:
sideshowbarker
2024-07-19 00:08:32 +09:00
Author: https://github.com/tomuta
Commit: cf89180c35
Pull-request: https://github.com/SerenityOS/serenity/pull/4736
12 changed files with 94 additions and 74 deletions
|
@ -37,7 +37,7 @@ namespace Core {
|
|||
|
||||
HashMap<uid_t, String> ProcessStatisticsReader::s_usernames;
|
||||
|
||||
HashMap<pid_t, Core::ProcessStatistics> ProcessStatisticsReader::get_all()
|
||||
Optional<HashMap<pid_t, Core::ProcessStatistics>> ProcessStatisticsReader::get_all()
|
||||
{
|
||||
auto file = Core::File::construct("/proc/all");
|
||||
if (!file->open(Core::IODevice::ReadOnly)) {
|
||||
|
@ -49,7 +49,8 @@ HashMap<pid_t, Core::ProcessStatistics> ProcessStatisticsReader::get_all()
|
|||
|
||||
auto file_contents = file->read_all();
|
||||
auto json = JsonValue::from_string(file_contents);
|
||||
ASSERT(json.has_value());
|
||||
if (!json.has_value())
|
||||
return {};
|
||||
json.value().as_array().for_each([&](auto& value) {
|
||||
const JsonObject& process_object = value.as_object();
|
||||
Core::ProcessStatistics process;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue