Canop / Canop/bacon

`bacon` sometimes misses non-zero exit codes

Open
#403 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
3.4k
Forks
126
Avg merge
2d 1h
Merged PRs (30d)
7

Description

Usually when a command run through `bacon` exits with a non-zero exit code, `bacon` prints `Command error code: ` in the top status bar. This does not always work.

Small reproducer (in an empty `cargo` project):
`src/main.rs`:
```rust
use std::process::ExitCode;

fn main() -> ExitCode {
println!("program ran");
ExitCode::FAILURE
}
```

No `bacon.toml`/global `bacon` config file.

Run `bacon run` and keep pressing `r`. Eventually there will be a run where the `Command error code` message is not shown.

Alternatively, this small script runs `bacon` in a loop until the message is missing:
```bash
while true; do
(sleep 1s; killall bacon) & /usr/bin/bacon run > out 2>&1
if grep -q "program ran" out && ! grep -q "Command error code: 1" out; then
break
fi
done
```

For me, it took about a minute to reproduce with this script.

For this simple program, it doesn’t happen very often (maybe 1% of the time), but in a real project (which prints about 120 lines and overall takes about 200ms to run), this happens at a noticeable rate, maybe 50%.

Slightly larger reproducer that makes manual reproduction easier:
```rust
use std::process::ExitCode;
use std::time::Duration;

fn main() -> ExitCode {
for i in 0..1000 {
println!("{}", i.to_string().repeat(i));
}
std::thread::sleep(Duration::from_millis(150));
println!("program ran");
ExitCode::FAILURE
}
```

More output and longer execution times seem to make it happen more often.

As a small check that it’s not `cargo` that’s swallowing the exit code, this does not terminate for me:
```bash
while ! cargo run; do true; done
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.