fix: read task hang when the cgroup dir removed after open

Fixes #62
Signed-off-by: quanweiZhou <quanweiZhou@linux.alibaba.com>
This commit is contained in:
quanwei.zqw
2021-11-10 10:51:11 +08:00
committed by quanweiZhou
parent 0233c1e046
commit fb55383273
2 changed files with 9 additions and 4 deletions
+1 -1
View File
@@ -87,7 +87,7 @@ fn mountinfo_file(file: &mut File) -> Vec<Mountinfo> {
} }
} }
} }
Err(_) => continue, Err(_) => break,
} }
} }
r r
+8 -3
View File
@@ -365,9 +365,14 @@ where
.map(|file| { .map(|file| {
let bf = BufReader::new(file); let bf = BufReader::new(file);
let mut v = Vec::new(); let mut v = Vec::new();
for line in bf.lines().flatten() { for line in bf.lines() {
let n = line.trim().parse().unwrap_or(0u64); match line {
v.push(n); Ok(line) => {
let n = line.trim().parse().unwrap_or(0u64);
v.push(n);
}
Err(_) => break,
}
} }
v.into_iter().map(CgroupPid::from).collect() v.into_iter().map(CgroupPid::from).collect()
}) })