diff options
author | GuillaumeGas <guillaume@gas-ntic.fr> | 2019-05-16 18:47:47 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-05-16 18:47:47 +0200 |
commit | 0ba4ceb2cd1768336116368a360acc922091e63a (patch) | |
tree | 43156868d17b180bc5b751ce29bdfebc6f32a1cd /LibCore/CProcessStatisticsReader.h | |
parent | 174639b7f06ec9e5f09dfa7f59dc5b62d2940fc6 (diff) | |
download | serenity-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.h | 29 |
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; +}; |