File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Expand file tree Collapse file tree 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() {
15721572#[ test]
15731573#[ cfg( target_os = "linux" ) ]
15741574fn test_read_dir_infinite_loop ( ) {
1575+ use crate :: io:: ErrorKind ;
15751576 use crate :: process:: Command ;
1576- use crate :: thread:: sleep;
1577- use crate :: time:: Duration ;
15781577
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 } ;
15811580
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+ }
15851587
15861588 // open() on this path will succeed, but readdir() will fail
15871589 let id = child. id ( ) ;
You can’t perform that action at this time.
0 commit comments