File tree Expand file tree Collapse file tree 1 file changed +4
-16
lines changed Expand file tree Collapse file tree 1 file changed +4
-16
lines changed Original file line number Diff line number Diff line change 14
14
target_os = "dragonfly" ,
15
15
) ) ]
16
16
fn main ( ) -> std:: io:: Result < ( ) > {
17
- use std:: { num :: NonZeroI32 , process:: Command } ;
17
+ use std:: process:: Command ;
18
18
19
19
use async_io:: os:: kqueue:: { Exit , Filter } ;
20
20
use futures_lite:: future;
21
21
22
22
future:: block_on ( async {
23
23
// Spawn a process.
24
- let mut process = Command :: new ( "sleep" )
24
+ let process = Command :: new ( "sleep" )
25
25
. arg ( "3" )
26
26
. spawn ( )
27
27
. expect ( "failed to spawn process" ) ;
28
28
29
29
// Wrap the process in an `Async` object that waits for it to exit.
30
- let process_handle = unsafe {
31
- Filter :: new ( Exit :: from_pid (
32
- NonZeroI32 :: new ( process. id ( ) . try_into ( ) . expect ( "invalid process pid" ) )
33
- . expect ( "non zero pid" ) ,
34
- ) ) ?
35
- } ;
30
+ let process = Filter :: new ( Exit :: new ( process) ) ?;
36
31
37
32
// Wait for the process to exit.
38
- process_handle . ready ( ) . await ?;
33
+ process . ready ( ) . await ?;
39
34
40
- println ! (
41
- "Process exit code {:?}" ,
42
- process
43
- . try_wait( )
44
- . expect( "error while waiting process" )
45
- . expect( "process did not exit yet" )
46
- ) ;
47
35
Ok ( ( ) )
48
36
} )
49
37
}
You can’t perform that action at this time.
0 commit comments