From dfdf69606265a7a7367963ed2cff5e3232f19b89 Mon Sep 17 00:00:00 2001 From: jif-oai Date: Wed, 17 Dec 2025 18:16:19 +0000 Subject: [PATCH] NIT --- codex-rs/utils/pty/src/fallback.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/codex-rs/utils/pty/src/fallback.rs b/codex-rs/utils/pty/src/fallback.rs index 9164a3982b..bffcbf0e78 100644 --- a/codex-rs/utils/pty/src/fallback.rs +++ b/codex-rs/utils/pty/src/fallback.rs @@ -78,8 +78,10 @@ pub async fn spawn_piped_process( let wait_child = Arc::clone(&child); let wait_handle: JoinHandle<()> = tokio::task::spawn_blocking(move || { let code = loop { - let mut guard = wait_child.blocking_lock(); - let status = guard.try_wait(); + let status = { + let mut guard = wait_child.blocking_lock(); + guard.try_wait() + }; match status { Ok(Some(status)) => { break status @@ -149,8 +151,16 @@ impl PipedChildKiller { impl portable_pty::ChildKiller for PipedChildKiller { fn kill(&mut self) -> io::Result<()> { - let mut guard = self.child.blocking_lock(); - guard.kill() + if let Ok(mut guard) = self.child.try_lock() { + return guard.kill(); + } + + let child = Arc::clone(&self.child); + std::thread::spawn(move || { + let mut guard = child.blocking_lock(); + let _ = guard.kill(); + }); + Ok(()) } fn clone_killer(&self) -> Box {