Skip to content

Commit

Permalink
Speed up procfs scanning
Browse files Browse the repository at this point in the history
  • Loading branch information
vrmiguel committed Oct 30, 2023
1 parent fab04c5 commit 5cf0867
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions src/kill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,7 @@ pub fn choose_victim(

let mut processes = fs::read_dir("/proc/")?
.filter_map(|e| e.ok())
.filter_map(|entry| {
entry
.path()
.file_name()
.unwrap_or_else(|| OsStr::new("0"))
.to_str()
.unwrap_or("0")
.trim()
.parse::<u32>()
.ok()
})
.filter_map(|entry| entry.file_name().to_str()?.trim().parse::<u32>().ok())
.filter(|pid| *pid > 1)
.filter_map(|pid| Process::from_pid(pid, proc_buf).ok());

Expand Down

0 comments on commit 5cf0867

Please sign in to comment.