Fix release CI test failures caused by telemetry fork flushing stdout

The double-fork in spawn_detached_unix inherited unflushed stdout/stderr
buffers from the parent process. When the intermediate child called
std::process::exit(0), libc cleanup flushed these buffers again, causing
duplicate output that broke trycmd snapshot comparisons in release builds
(where telemetry defaults to enabled).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Bryan Helmkamp 2026-03-19 15:18:03 -04:00
parent 0fdf355d39
commit 0937d5ce48

View file

@ -25,6 +25,13 @@ pub fn spawn_detached(args: &[&str], env: &[(&str, &str)]) {
fn spawn_detached_unix(args: &[&str], env: &[(&str, &str)]) {
use fork::{fork, setsid, Fork};
// Flush stdout/stderr before forking so the child process doesn't inherit
// buffered data that would be flushed again on child exit, causing
// duplicate or corrupted output.
use std::io::Write;
let _ = std::io::stdout().flush();
let _ = std::io::stderr().flush();
// First fork — parent returns immediately.
match fork() {
Ok(Fork::Parent(_)) => {}