Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Karthik Uthaman committed Jan 29, 2025
1 parent 435f428 commit a75f42e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/common/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1888,7 +1888,7 @@ impl ProcessRefreshKind {
environ: UpdateKind::OnlyIfNotSet,
cmd: UpdateKind::OnlyIfNotSet,
exe: UpdateKind::OnlyIfNotSet,
thread: false,
thread: true,
}
}

Expand Down
14 changes: 10 additions & 4 deletions src/unix/linux/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ fn get_all_pid_entries(
parent_pid: Option<Pid>,
entry: DirEntry,
data: &mut Vec<ProcAndTasks>,
refresh_kind: ProcessRefreshKind,
enable_thread_stats: bool,
) -> Option<Pid> {
let Ok(file_type) = entry.file_type() else {
return None;
Expand All @@ -679,12 +679,18 @@ fn get_all_pid_entries(
let name = name?;
let pid = Pid::from(usize::from_str(name.to_str()?).ok()?);

let tasks = if refresh_kind.thread() {
let tasks = if enable_thread_stats {
let tasks_dir = Path::join(&entry, "task");
if let Ok(entries) = fs::read_dir(tasks_dir) {
let mut tasks = HashSet::new();
for task in entries.into_iter().filter_map(|entry| {
get_all_pid_entries(Some(name), Some(pid), entry.ok()?, data, refresh_kind)
get_all_pid_entries(
Some(name),
Some(pid),
entry.ok()?,
data,
enable_thread_stats,
)
}) {
tasks.insert(task);
}
Expand Down Expand Up @@ -776,7 +782,7 @@ pub(crate) fn refresh_procs(
.map(|entry| {
let Ok(entry) = entry else { return Vec::new() };
let mut entries = Vec::new();
get_all_pid_entries(None, None, entry, &mut entries, refresh_kind);
get_all_pid_entries(None, None, entry, &mut entries, refresh_kind.thread());
entries
})
.flatten()
Expand Down

0 comments on commit a75f42e

Please sign in to comment.