summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Applications/ProcessManager/ProcessModel.cpp15
-rw-r--r--Applications/ProcessManager/ProcessModel.h2
2 files changed, 10 insertions, 7 deletions
diff --git a/Applications/ProcessManager/ProcessModel.cpp b/Applications/ProcessManager/ProcessModel.cpp
index 9161920619..e9eae323dc 100644
--- a/Applications/ProcessManager/ProcessModel.cpp
+++ b/Applications/ProcessManager/ProcessModel.cpp
@@ -7,7 +7,13 @@
ProcessModel::ProcessModel(GraphWidget& graph)
: m_graph(graph)
+ , m_proc_all("/proc/all")
{
+ if (!m_proc_all.open(CIODevice::ReadOnly)) {
+ fprintf(stderr, "ProcessManager: Failed to open /proc/all: %s\n", m_proc_all.error_string());
+ exit(1);
+ }
+
setpwent();
while (auto* passwd = getpwent())
m_usernames.set(passwd->pw_uid, passwd->pw_name);
@@ -137,12 +143,7 @@ GVariant ProcessModel::data(const GModelIndex& index, Role role) const
void ProcessModel::update()
{
- CFile file("/proc/all");
- if (!file.open(CIODevice::ReadOnly)) {
- fprintf(stderr, "ProcessManager: Failed to open /proc/all: %s\n", file.error_string());
- exit(1);
- return;
- }
+ m_proc_all.seek(0);
unsigned last_sum_nsched = 0;
for (auto& it : m_processes)
@@ -151,7 +152,7 @@ void ProcessModel::update()
HashTable<pid_t> live_pids;
unsigned sum_nsched = 0;
for (;;) {
- auto line = file.read_line(1024);
+ auto line = m_proc_all.read_line(1024);
if (line.is_empty())
break;
auto chomped = String((const char*)line.pointer(), line.size() - 1, Chomp);
diff --git a/Applications/ProcessManager/ProcessModel.h b/Applications/ProcessManager/ProcessModel.h
index c552c3ec3d..92ff292a0b 100644
--- a/Applications/ProcessManager/ProcessModel.h
+++ b/Applications/ProcessManager/ProcessModel.h
@@ -4,6 +4,7 @@
#include <AK/HashMap.h>
#include <AK/Vector.h>
#include <LibGUI/GModel.h>
+#include <LibCore/CFile.h>
#include <unistd.h>
class GraphWidget;
@@ -64,4 +65,5 @@ private:
RetainPtr<GraphicsBitmap> m_high_priority_icon;
RetainPtr<GraphicsBitmap> m_low_priority_icon;
RetainPtr<GraphicsBitmap> m_normal_priority_icon;
+ CFile m_proc_all;
};