Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions cmux-tui/crates/cmux-tui-core/src/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2563,17 +2563,29 @@ impl Surface {

// Child reaper: retain the native status and rendezvous with PTY EOF
// so final output is visible before the mux observes completion.
std::thread::Builder::new().name(format!("surface-{id}-wait")).spawn({
let child_slot = Arc::new(Mutex::new(Some(child)));
let child_for_reaper = child_slot.clone();
let reaper = std::thread::Builder::new().name(format!("surface-{id}-wait")).spawn({
let surface = surface.clone();
move || {
let mut child =
child_for_reaper.lock().unwrap().take().expect("child reaper owns child");
let exit = wait_for_native_child_status(child.as_mut());
if let Some(pty) = surface.as_pty() {
*pty.exit.lock().unwrap() = Some(exit);
}
close_local_terminal_master_after_exit(&surface);
publish_local_exit_if_ready(&surface);
}
})?;
});
if let Err(error) = reaper {
if let Some(mut child) = child_slot.lock().unwrap().take() {
let _ = child.kill();
let _ = child.wait();
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
close_local_terminal_master_after_exit(&surface);
return Err(error.into());
}

Ok(surface)
}
Expand Down
Loading