Skip to content

Commit 701333c

Browse files
committed
ps: Only include basic_collector if no other arguments
Otherwise listed processes would always be a super-set of what the default output lists, which is not correct since for example `ps -d` would report too many processes.
1 parent 49c7d72 commit 701333c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/uu/ps/src/ps.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
3838
.collect::<Vec<_>>();
3939
let mut proc_infos = Vec::new();
4040

41-
proc_infos.extend(collector::basic_collector(&snapshot));
42-
proc_infos.extend(collector::process_collector(&matches, &snapshot));
43-
proc_infos.extend(collector::session_collector(&matches, &snapshot));
41+
if !matches.get_flag("A") && !matches.get_flag("a") && !matches.get_flag("d") {
42+
proc_infos.extend(collector::basic_collector(&snapshot));
43+
} else {
44+
proc_infos.extend(collector::process_collector(&matches, &snapshot));
45+
proc_infos.extend(collector::session_collector(&matches, &snapshot));
46+
}
4447

4548
proc_infos.sort_by(|a, b| a.borrow().pid.cmp(&b.borrow().pid));
4649
proc_infos.dedup_by(|a, b| a.borrow().pid == b.borrow().pid);

0 commit comments

Comments
 (0)