Skip to content

Commit 6c4cf30

Browse files
committed
[AIX] Update tests/ui/wait-forked-but-failed-child.rs to accomodate exiting and idle processes.
1 parent 01e4f19 commit 6c4cf30

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tests/ui/wait-forked-but-failed-child.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,17 @@ fn find_zombies() {
3131
// https://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html
3232
let ps_cmd_output = Command::new("ps").args(&["-A", "-o", "pid,ppid,args"]).output().unwrap();
3333
let ps_output = String::from_utf8_lossy(&ps_cmd_output.stdout);
34+
// On AIX, the PPID is not always present, such as when a process is blocked
35+
// (marked as <exiting>), or if a process is idle. In these situations,
36+
// the PPID column contains a "-" for the respective process.
37+
// Filter out any lines that have a "-" as the PPID as the PPID is
38+
// expected to be an integer.
39+
let filtered_ps: Vec<_> = ps_output
40+
.lines()
41+
.filter(|line| line.split(' ').filter(|x| 0 < x.len()).nth(1) != Some("-"))
42+
.collect();
3443

35-
for (line_no, line) in ps_output.split('\n').enumerate() {
44+
for (line_no, line) in filtered_ps.into_iter().enumerate() {
3645
if 0 < line_no && 0 < line.len() &&
3746
my_pid == line.split(' ').filter(|w| 0 < w.len()).nth(1)
3847
.expect("1st column should be PPID")

0 commit comments

Comments
 (0)