Skip to content

Commit 610773a

Browse files
committed
rollback to basic kqueue example
1 parent 4308464 commit 610773a

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

examples/kqueue-process.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,24 @@
1414
target_os = "dragonfly",
1515
))]
1616
fn main() -> std::io::Result<()> {
17-
use std::{num::NonZeroI32, process::Command};
17+
use std::process::Command;
1818

1919
use async_io::os::kqueue::{Exit, Filter};
2020
use futures_lite::future;
2121

2222
future::block_on(async {
2323
// Spawn a process.
24-
let mut process = Command::new("sleep")
24+
let process = Command::new("sleep")
2525
.arg("3")
2626
.spawn()
2727
.expect("failed to spawn process");
2828

2929
// 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))?;
3631

3732
// Wait for the process to exit.
38-
process_handle.ready().await?;
33+
process.ready().await?;
3934

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-
);
4735
Ok(())
4836
})
4937
}

0 commit comments

Comments
 (0)