mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
fs/tests: Explicitly kill the zombie rather than sleeping until it dies
This commit is contained in:
parent
ba4dd464f5
commit
1550a2506d
@ -1572,16 +1572,18 @@ fn test_eq_direntry_metadata() {
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
fn test_read_dir_infinite_loop() {
|
||||
use crate::io::ErrorKind;
|
||||
use crate::process::Command;
|
||||
use crate::thread::sleep;
|
||||
use crate::time::Duration;
|
||||
|
||||
// Create a child process
|
||||
let Ok(child) = Command::new("echo").spawn() else { return };
|
||||
// Create a zombie child process
|
||||
let Ok(mut child) = Command::new("echo").spawn() else { return };
|
||||
|
||||
// Wait for it to (probably) become a zombie. We can't use wait() because
|
||||
// that will reap the process.
|
||||
sleep(Duration::from_millis(10));
|
||||
// Make sure the process is (un)dead
|
||||
match child.kill() {
|
||||
// InvalidInput means the child already exited
|
||||
Err(e) if e.kind() != ErrorKind::InvalidInput => return,
|
||||
_ => {}
|
||||
}
|
||||
|
||||
// open() on this path will succeed, but readdir() will fail
|
||||
let id = child.id();
|
||||
|
Loading…
Reference in New Issue
Block a user