From 0937d5ce4843f786e99cda2788e343e883a47066 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Thu, 19 Mar 2026 15:18:03 -0400 Subject: [PATCH] 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) --- lib/crates/fabro-telemetry/src/spawn.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/crates/fabro-telemetry/src/spawn.rs b/lib/crates/fabro-telemetry/src/spawn.rs index 8626def60..0d02a64b6 100644 --- a/lib/crates/fabro-telemetry/src/spawn.rs +++ b/lib/crates/fabro-telemetry/src/spawn.rs @@ -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(_)) => {}