From 79ad7b7ec2f38df3a799ce730dd13bec1b4e3072 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 4 Apr 2019 09:25:19 +0200 Subject: [PATCH] src/tools/procfs.rs: split regex into several lines --- src/tools/procfs.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/tools/procfs.rs b/src/tools/procfs.rs index 9c81531a..06561ef5 100644 --- a/src/tools/procfs.rs +++ b/src/tools/procfs.rs @@ -18,7 +18,12 @@ pub fn read_proc_pid_stat(pid: libc::pid_t) -> Result { let statstr = tools::file_read_firstline(format!("/proc/{}/stat", pid))?; lazy_static! { - static ref REGEX: Regex = Regex::new(r"^(?P\d+) \(.*\) (?P\S) -?\d+ -?\d+ -?\d+ -?\d+ -?\d+ \d+ \d+ \d+ \d+ \d+ (?P\d+) (?P\d+) -?\d+ -?\d+ -?\d+ -?\d+ -?\d+ 0 (?P\d+) (?P\d+) (?P-?\d+) \d+ \d+ \d+ \d+ \d+ \d+ \d+ \d+ \d+ \d+ \d+ \d+ \d+ -?\d+ -?\d+ \d+ \d+ \d+").unwrap(); + static ref REGEX: Regex = Regex::new(concat!( + r"^(?P\d+) \(.*\) (?P\S) -?\d+ -?\d+ -?\d+ -?\d+ -?\d+ \d+ \d+ \d+ \d+ \d+ ", + r"(?P\d+) (?P\d+) -?\d+ -?\d+ -?\d+ -?\d+ -?\d+ 0 ", + r"(?P\d+) (?P\d+) (?P-?\d+) ", + r"\d+ \d+ \d+ \d+ \d+ \d+ \d+ \d+ \d+ \d+ \d+ \d+ \d+ -?\d+ -?\d+ \d+ \d+ \d+" + )).unwrap(); } if let Some(cap) = REGEX.captures(&statstr) {