summaryrefslogtreecommitdiff
path: root/LibCore/CProcessStatisticsReader.h
diff options
context:
space:
mode:
authorGuillaumeGas <guillaume@gas-ntic.fr>2019-05-16 18:47:47 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-05-16 18:47:47 +0200
commit0ba4ceb2cd1768336116368a360acc922091e63a (patch)
tree43156868d17b180bc5b751ce29bdfebc6f32a1cd /LibCore/CProcessStatisticsReader.h
parent174639b7f06ec9e5f09dfa7f59dc5b62d2940fc6 (diff)
downloadserenity-0ba4ceb2cd1768336116368a360acc922091e63a.zip
Added CProcessStatisticsReader to avoid having to parse /proc/all (#35)
* Added CProcessStatisticsReader to avoid having to parse /proc/all * Took @awesomekling's feedbacks into account * Fixed indentation and replaced tabs by spaces
Diffstat (limited to 'LibCore/CProcessStatisticsReader.h')
-rw-r--r--LibCore/CProcessStatisticsReader.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/LibCore/CProcessStatisticsReader.h b/LibCore/CProcessStatisticsReader.h
new file mode 100644
index 0000000000..2ce97e9f68
--- /dev/null
+++ b/LibCore/CProcessStatisticsReader.h
@@ -0,0 +1,29 @@
+#pragma once
+
+#include <AK/AKString.h>
+#include <AK/HashMap.h>
+
+struct CProcessStatistics {
+ pid_t pid;
+ unsigned nsched;
+ String name;
+ String state;
+ String username;
+ uid_t uid;
+ String priority;
+ size_t linear;
+ size_t physical;
+ unsigned syscalls;
+};
+
+class CProcessStatisticsReader {
+public:
+ CProcessStatisticsReader();
+ HashMap<pid_t, CProcessStatistics> get_map();
+
+private:
+ void update_map(HashMap<pid_t, CProcessStatistics>& map);
+ String get_username_from_uid(const uid_t uid);
+
+ HashMap<uid_t, String> m_usernames;
+};