• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use libc::{kill, SIGSTOP};
2 use rustix::process;
3 use std::process::{Command, Stdio};
4 
5 // These tests must execute serially to prevent race condition, where
6 // `test_wait` waits for the child process spawned in `test_waitpid`, causing
7 // the tests to get stuck.
8 
9 #[test]
10 #[ignore]
test_waitpid()11 fn test_waitpid() {
12     let child = Command::new("yes")
13         .stdout(Stdio::null())
14         .stderr(Stdio::null())
15         .spawn()
16         .expect("failed to execute child");
17     unsafe { kill(child.id() as _, SIGSTOP) };
18 
19     let pid = unsafe { process::Pid::from_raw(child.id() as _) };
20     let status = process::waitpid(pid, process::WaitOptions::UNTRACED)
21         .expect("failed to wait")
22         .unwrap();
23     assert!(status.stopped());
24 }
25