bacon
bacon copied to clipboard
`stdout` and `stderr` are sometimes interleaved
When a command produces output on both stdout and stderr, sometimes both are interleaved.
Small reproducer (with cargo new t && cd t):
src/main.rs:
fn main() {
for i in 0..10 {
println!("stdout: {i}");
}
for i in 0..10 {
eprintln!("stderr: {i}");
}
}
bacon run:
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.01s
Running `target/debug/t`
stdout: 0
stderr: 0
stdout: 1
stdout: 2
stdout: 3
stdout: 4
stdout: 5
stdout: 6
stdout: 7
stdout: 8
stdout: 9
stderr: 1
stderr: 2
stderr: 3
stderr: 4
stderr: 5
stderr: 6
stderr: 7
stderr: 8
stderr: 9
(This sometimes needs a few tries.)
This is especially noticeable when the program normally produces output on stdout and then dbg!() is used to produce additional debug output.
$ bacon --version
bacon 3.14.0
Hum. I'm not sure I can even change that without introducing a costly semaphore.
Would std::io::pipe help?
Would
std::io::pipehelp?
I don't know. Part of the problem is we still need to know the origin (out or err) of the bytes we receive.