Read the process's major page faults from `/proc/self/stat`. Returns `None` on non-Linux or if the file can't be read.
()
| 188 | /// |
| 189 | /// Returns `None` on non-Linux or if the file can't be read. |
| 190 | pub fn read_process_majflt() -> Option<u64> { |
| 191 | let stat = std::fs::read_to_string("/proc/self/stat").ok()?; |
| 192 | // Field 12 (0-indexed) is majflt. |
| 193 | let fields: Vec<&str> = stat.split_whitespace().collect(); |
| 194 | fields.get(11)?.parse::<u64>().ok() |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | #[cfg(test)] |