File tree 1 file changed +9
-7
lines changed
1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -1572,16 +1572,18 @@ fn test_eq_direntry_metadata() {
1572
1572
#[ test]
1573
1573
#[ cfg( target_os = "linux" ) ]
1574
1574
fn test_read_dir_infinite_loop ( ) {
1575
+ use crate :: io:: ErrorKind ;
1575
1576
use crate :: process:: Command ;
1576
- use crate :: thread:: sleep;
1577
- use crate :: time:: Duration ;
1578
1577
1579
- // Create a child process
1580
- let Ok ( child) = Command :: new ( "echo" ) . spawn ( ) else { return } ;
1578
+ // Create a zombie child process
1579
+ let Ok ( mut child) = Command :: new ( "echo" ) . spawn ( ) else { return } ;
1581
1580
1582
- // Wait for it to (probably) become a zombie. We can't use wait() because
1583
- // that will reap the process.
1584
- sleep ( Duration :: from_millis ( 10 ) ) ;
1581
+ // Make sure the process is (un)dead
1582
+ match child. kill ( ) {
1583
+ // InvalidInput means the child already exited
1584
+ Err ( e) if e. kind ( ) != ErrorKind :: InvalidInput => return ,
1585
+ _ => { }
1586
+ }
1585
1587
1586
1588
// open() on this path will succeed, but readdir() will fail
1587
1589
let id = child. id ( ) ;
You can’t perform that action at this time.
0 commit comments