diff --git a/crates/turborepo-ui/src/tui/clipboard.rs b/crates/turborepo-ui/src/tui/clipboard.rs index ec95d624b18f2..c9260d7e5f7f3 100644 --- a/crates/turborepo-ui/src/tui/clipboard.rs +++ b/crates/turborepo-ui/src/tui/clipboard.rs @@ -86,8 +86,6 @@ fn copy_impl(s: &str, provider: &Provider) -> std::io::Result<()> { } Provider::Exec(prog, args) => { - // Child::wait is run after writing `s` into stdin - #[allow(clippy::zombie_processes)] let mut child = std::process::Command::new(prog) .args(args) .stdin(Stdio::piped()) @@ -95,8 +93,13 @@ fn copy_impl(s: &str, provider: &Provider) -> std::io::Result<()> { .stderr(Stdio::null()) .spawn() .unwrap(); - std::io::Write::write_all(&mut child.stdin.as_ref().unwrap(), s.as_bytes())?; - child.wait()?; + // Do not exit early if we fail to write to the clipboard, make sure we attempt + // to wait on the clipboard to exit to avoid a zombie process. + let write_result = + std::io::Write::write_all(&mut child.stdin.as_ref().unwrap(), s.as_bytes()); + let wait_result = child.wait(); + write_result?; + wait_result?; } #[cfg(windows)]