File tree Expand file tree Collapse file tree
library/std/src/sys/process/windows Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11use super :: { Arg , make_command_line} ;
22use crate :: env;
33use crate :: ffi:: { OsStr , OsString } ;
4- use crate :: process:: Command ;
4+ use crate :: os:: windows:: io:: AsHandle ;
5+ use crate :: process:: { Command , Stdio } ;
56
67#[ test]
78fn test_raw_args ( ) {
@@ -29,19 +30,21 @@ fn test_thread_handle() {
2930 use crate :: os:: windows:: process:: { ChildExt , CommandExt } ;
3031 const CREATE_SUSPENDED : u32 = 0x00000004 ;
3132
32- let p = Command :: new ( "cmd " ) . args ( & [ "/C" , "exit 0" ] ) . creation_flags ( CREATE_SUSPENDED ) . spawn ( ) ;
33+ let p = Command :: new ( "whoami " ) . stdout ( Stdio :: null ( ) ) . creation_flags ( CREATE_SUSPENDED ) . spawn ( ) ;
3334 assert ! ( p. is_ok( ) ) ;
3435 let mut p = p. unwrap ( ) ;
3536
3637 unsafe extern "system" {
37- fn ResumeThread ( _: BorrowedHandle < ' _ > ) -> u32 ;
38+ unsafe fn ResumeThread ( hHandle : BorrowedHandle < ' _ > ) -> u32 ;
39+ unsafe fn WaitForSingleObject ( hHandle : BorrowedHandle < ' _ > , dwMilliseconds : u32 ) -> u32 ;
3840 }
3941 unsafe {
4042 ResumeThread ( p. main_thread_handle ( ) ) ;
43+ // Wait until the process exits or 1 minute passes.
44+ // We don't bother checking the result here as that's done below using `try_wait`.
45+ WaitForSingleObject ( p. as_handle ( ) , 1000 * 60 ) ;
4146 }
4247
43- crate :: thread:: sleep ( crate :: time:: Duration :: from_millis ( 100 ) ) ;
44-
4548 let res = p. try_wait ( ) ;
4649 assert ! ( res. is_ok( ) ) ;
4750 assert ! ( res. unwrap( ) . is_some( ) ) ;
You can’t perform that action at this time.
0 commit comments