Skip to content

Commit 8aa6cfb

Browse files
authored
Rollup merge of #136556 - amy-kwan:amy-kwan/update_wait-forked-but-failed-child.rs, r=joboet
[AIX] Update tests/ui/wait-forked-but-failed-child.rs to accomodate exiting and idle processes. The `wait-forked-but-failed-child.rs` test expects to see an integer PPID in the output of the command: `ps -A -o pid,ppid,args`. However, on AIX, sometimes an integer PPID is not available when a process is either exiting or idle, as documented in https://www.ibm.com/docs/en/aix/7.3?topic=p-ps-command. In these situations, a `-` is instead shown in the PPID column of the `ps` output. This PR updates the test to accommodate this behaviour on AIX by first filtering out the lines of the `ps` output where a `-` is found in the `PPID` column.
2 parents 7ca0fd1 + bdaf7a8 commit 8aa6cfb

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_whitespace().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)