Filter process file metadata instead of panicking
Gracefully filter process file metadata instead of panicking, because there's a non-zero chance this error will be encountered when processes are being added or removed from procfs.
This commit is contained in:
parent
974307a22d
commit
adf9686ec3
1 changed files with 2 additions and 2 deletions
|
@ -214,10 +214,10 @@ fn procfs() -> Result<Vec<(i32, u64)>, Error> {
|
||||||
Ok(read_dir("/proc/")
|
Ok(read_dir("/proc/")
|
||||||
.prepend_io(|| "/proc/".into())?
|
.prepend_io(|| "/proc/".into())?
|
||||||
.filter_map(StdResult::ok)
|
.filter_map(StdResult::ok)
|
||||||
.filter_map(|s| procfs_meta(s).expect("Unable to obtain procfs metadata"))
|
.filter_map(|s| procfs_meta(s).map_or_else(|_| None, |x| x))
|
||||||
.filter_map(|(name, mtime)| {
|
.filter_map(|(name, mtime)| {
|
||||||
name.to_str()
|
name.to_str()
|
||||||
.expect("Invalid UTF-8 filename in procfs")
|
.expect("UTF-8 filename in procfs")
|
||||||
.parse()
|
.parse()
|
||||||
.map_or_else(|_| None, |v| Some((v, mtime)))
|
.map_or_else(|_| None, |v| Some((v, mtime)))
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue