diff options
author | Tom <tomut@yahoo.com> | 2021-01-01 20:58:47 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-03 22:12:19 +0100 |
commit | cf89180c350e59a8c7cf012544a1988ca1149010 (patch) | |
tree | 377a4ad610b7795b257fa811f2bd7f9e92d4eb82 /Applications | |
parent | 754bf22da72bfdf160549713655acde26bee580c (diff) | |
download | serenity-cf89180c350e59a8c7cf012544a1988ca1149010.zip |
LibCore: Report error condition when reading process statistics failed
Diffstat (limited to 'Applications')
-rw-r--r-- | Applications/SystemMonitor/ProcessModel.cpp | 96 |
1 files changed, 49 insertions, 47 deletions
diff --git a/Applications/SystemMonitor/ProcessModel.cpp b/Applications/SystemMonitor/ProcessModel.cpp index 657560b102..76562481a1 100644 --- a/Applications/SystemMonitor/ProcessModel.cpp +++ b/Applications/SystemMonitor/ProcessModel.cpp @@ -358,57 +358,59 @@ void ProcessModel::update() HashTable<PidAndTid> live_pids; u64 sum_ticks_scheduled = 0; - for (auto& it : all_processes) { - for (auto& thread : it.value.threads) { - ThreadState state; - state.pid = it.value.pid; - state.user = it.value.username; - state.pledge = it.value.pledge; - state.veil = it.value.veil; - state.syscall_count = thread.syscall_count; - state.inode_faults = thread.inode_faults; - state.zero_faults = thread.zero_faults; - state.cow_faults = thread.cow_faults; - state.unix_socket_read_bytes = thread.unix_socket_read_bytes; - state.unix_socket_write_bytes = thread.unix_socket_write_bytes; - state.ipv4_socket_read_bytes = thread.ipv4_socket_read_bytes; - state.ipv4_socket_write_bytes = thread.ipv4_socket_write_bytes; - state.file_read_bytes = thread.file_read_bytes; - state.file_write_bytes = thread.file_write_bytes; - state.amount_virtual = it.value.amount_virtual; - state.amount_resident = it.value.amount_resident; - state.amount_dirty_private = it.value.amount_dirty_private; - state.amount_clean_inode = it.value.amount_clean_inode; - state.amount_purgeable_volatile = it.value.amount_purgeable_volatile; - state.amount_purgeable_nonvolatile = it.value.amount_purgeable_nonvolatile; + if (all_processes.has_value()) { + for (auto& it : all_processes.value()) { + for (auto& thread : it.value.threads) { + ThreadState state; + state.pid = it.value.pid; + state.user = it.value.username; + state.pledge = it.value.pledge; + state.veil = it.value.veil; + state.syscall_count = thread.syscall_count; + state.inode_faults = thread.inode_faults; + state.zero_faults = thread.zero_faults; + state.cow_faults = thread.cow_faults; + state.unix_socket_read_bytes = thread.unix_socket_read_bytes; + state.unix_socket_write_bytes = thread.unix_socket_write_bytes; + state.ipv4_socket_read_bytes = thread.ipv4_socket_read_bytes; + state.ipv4_socket_write_bytes = thread.ipv4_socket_write_bytes; + state.file_read_bytes = thread.file_read_bytes; + state.file_write_bytes = thread.file_write_bytes; + state.amount_virtual = it.value.amount_virtual; + state.amount_resident = it.value.amount_resident; + state.amount_dirty_private = it.value.amount_dirty_private; + state.amount_clean_inode = it.value.amount_clean_inode; + state.amount_purgeable_volatile = it.value.amount_purgeable_volatile; + state.amount_purgeable_nonvolatile = it.value.amount_purgeable_nonvolatile; - state.name = thread.name; - state.executable = it.value.executable; + state.name = thread.name; + state.executable = it.value.executable; - state.ppid = it.value.ppid; - state.tid = thread.tid; - state.pgid = it.value.pgid; - state.sid = it.value.sid; - state.times_scheduled = thread.times_scheduled; - state.ticks_user = thread.ticks_user; - state.ticks_kernel = thread.ticks_kernel; - state.cpu = thread.cpu; - state.cpu_percent = 0; - state.priority = thread.priority; - state.effective_priority = thread.effective_priority; - state.state = thread.state; - sum_ticks_scheduled += thread.ticks_user + thread.ticks_kernel; - { + state.ppid = it.value.ppid; + state.tid = thread.tid; + state.pgid = it.value.pgid; + state.sid = it.value.sid; + state.times_scheduled = thread.times_scheduled; + state.ticks_user = thread.ticks_user; + state.ticks_kernel = thread.ticks_kernel; + state.cpu = thread.cpu; + state.cpu_percent = 0; + state.priority = thread.priority; + state.effective_priority = thread.effective_priority; + state.state = thread.state; + sum_ticks_scheduled += thread.ticks_user + thread.ticks_kernel; + { + auto pit = m_threads.find({ it.value.pid, thread.tid }); + if (pit == m_threads.end()) + m_threads.set({ it.value.pid, thread.tid }, make<Thread>()); + } auto pit = m_threads.find({ it.value.pid, thread.tid }); - if (pit == m_threads.end()) - m_threads.set({ it.value.pid, thread.tid }, make<Thread>()); - } - auto pit = m_threads.find({ it.value.pid, thread.tid }); - ASSERT(pit != m_threads.end()); - (*pit).value->previous_state = (*pit).value->current_state; - (*pit).value->current_state = state; + ASSERT(pit != m_threads.end()); + (*pit).value->previous_state = (*pit).value->current_state; + (*pit).value->current_state = state; - live_pids.set({ it.value.pid, thread.tid }); + live_pids.set({ it.value.pid, thread.tid }); + } } } |