Skip to content

Commit 1e91176

Browse files
committed
Fix test hangs on macos. (#1170)
In the `waitpid` tests, explicitly terminate the child processe and wait for them to exit, as dropping a `Command` otherwise leaves the process running. This fixes test hangs on macos.
1 parent 0f3ff9a commit 1e91176

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/process/wait.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ fn test_waitpid_none() {
2222
.expect("failed to wait")
2323
.unwrap();
2424
assert!(status.stopped());
25+
26+
// Clean up the child process.
27+
unsafe { kill(child.id() as _, SIGKILL) };
28+
29+
let status = process::waitpid(None, process::WaitOptions::UNTRACED)
30+
.expect("failed to wait")
31+
.unwrap();
32+
assert!(status.signaled());
2533
}
2634

2735
#[test]
@@ -39,6 +47,14 @@ fn test_waitpid_some() {
3947
.expect("failed to wait")
4048
.unwrap();
4149
assert!(status.stopped());
50+
51+
// Clean up the child process.
52+
unsafe { kill(child.id() as _, SIGKILL) };
53+
54+
let status = process::waitpid(Some(pid), process::WaitOptions::UNTRACED)
55+
.expect("failed to wait")
56+
.unwrap();
57+
assert!(status.signaled());
4258
}
4359

4460
#[test]
@@ -56,6 +72,14 @@ fn test_waitpgid() {
5672
.expect("failed to wait")
5773
.unwrap();
5874
assert!(status.stopped());
75+
76+
// Clean up the child process.
77+
unsafe { kill(child.id() as _, SIGKILL) };
78+
79+
let status = process::waitpgid(pgid, process::WaitOptions::UNTRACED)
80+
.expect("failed to wait")
81+
.unwrap();
82+
assert!(status.signaled());
5983
}
6084

6185
#[cfg(not(any(

0 commit comments

Comments
 (0)