From f8780ca1e76286688b74d8a6c64d5fadf3cfd2a1 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 28 Dec 2021 03:33:52 -0500 Subject: wip --- examples/interhack.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'examples/interhack.rs') diff --git a/examples/interhack.rs b/examples/interhack.rs index 8caebb4..e636282 100644 --- a/examples/interhack.rs +++ b/examples/interhack.rs @@ -5,7 +5,7 @@ mod main { use smol::io::{AsyncReadExt as _, AsyncWriteExt as _}; pub async fn run( - child: &pty_process::smol::Child, + child: &mut pty_process::smol::Child, ) -> std::result::Result<(), Box> { let _raw = super::raw_guard::RawGuard::new(); @@ -82,7 +82,12 @@ mod main { } }); - ex.run(smol::future::or(input, output)).await; + let wait = async { + child.status_no_drop().await.unwrap(); + }; + + ex.run(smol::future::or(smol::future::or(input, output), wait)) + .await; Ok(()) } @@ -90,7 +95,6 @@ mod main { #[cfg(feature = "backend-smol")] fn main() { - use pty_process::Command as _; use std::os::unix::process::ExitStatusExt as _; let (w, h) = if let Some((w, h)) = term_size::dimensions() { @@ -99,10 +103,12 @@ fn main() { (80, 24) }; let status = smol::block_on(async { - let mut child = smol::process::Command::new("nethack") - .spawn_pty(Some(&pty_process::Size::new(h, w))) + let pty = pty_process::smol::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(&child).await.unwrap(); + main::run(&mut child).await.unwrap(); child.status().await.unwrap() }); std::process::exit( -- cgit v1.2.3-54-g00ecf