From 3b550f5d3dad77a56455352579fae3071b42e86d Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 29 Dec 2021 02:55:24 -0500 Subject: wip another complete refactor --- examples/interhack.rs | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'examples/interhack.rs') diff --git a/examples/interhack.rs b/examples/interhack.rs index e636282..9d44bbf 100644 --- a/examples/interhack.rs +++ b/examples/interhack.rs @@ -1,11 +1,11 @@ mod raw_guard; -#[cfg(feature = "backend-smol")] +#[cfg(feature = "async")] mod main { use smol::io::{AsyncReadExt as _, AsyncWriteExt as _}; pub async fn run( - child: &mut pty_process::smol::Child, + child: &pty_process::Child, ) -> std::result::Result<(), Box> { let _raw = super::raw_guard::RawGuard::new(); @@ -71,11 +71,7 @@ mod main { stdout.flush().await.unwrap(); } Err(e) => { - // EIO means that the process closed the other - // end of the pty - if e.raw_os_error() != Some(libc::EIO) { - eprintln!("pty read failed: {:?}", e); - } + eprintln!("pty read failed: {:?}", e); break; } } @@ -93,7 +89,7 @@ mod main { } } -#[cfg(feature = "backend-smol")] +#[cfg(feature = "async")] fn main() { use std::os::unix::process::ExitStatusExt as _; @@ -103,12 +99,11 @@ fn main() { (80, 24) }; let status = smol::block_on(async { - let pty = pty_process::smol::Pty::new().unwrap(); + let pty = pty_process::Pty::new().unwrap(); pty.resize(pty_process::Size::new(h, w)).unwrap(); - let mut child = pty_process::smol::Command::new("nethack") - .spawn(pty) - .unwrap(); - main::run(&mut child).await.unwrap(); + let mut child = + pty_process::Command::new("nethack").spawn(pty).unwrap(); + main::run(&child).await.unwrap(); child.status().await.unwrap() }); std::process::exit( @@ -118,7 +113,7 @@ fn main() { ); } -#[cfg(not(feature = "backend-smol"))] +#[cfg(not(feature = "async"))] fn main() { unimplemented!() } -- cgit v1.2.3-54-g00ecf