Skip to content

Commit ebf2999

Browse files
kixelatedclaude
andauthored
moq-boy: exit non-zero on reconnect give-up instead of hanging (#1589)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent b7a08ff commit ebf2999

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

rs/moq-boy/src/main.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,9 +446,21 @@ async fn main() -> Result<()> {
446446
#[cfg(not(feature = "jemalloc"))]
447447
let jemalloc = std::future::pending::<anyhow::Result<()>>();
448448

449-
tokio::select! {
449+
let result = tokio::select! {
450450
res = run(&config) => res,
451451
Err(err) = jemalloc => Err(err).context("jemalloc profiler failed"),
452-
_ = tokio::signal::ctrl_c() => std::process::exit(0),
452+
res = tokio::signal::ctrl_c() => res.context("failed to listen for ctrl-c"),
453+
};
454+
455+
// run() owns a spawn_blocking emulator thread that loops forever. Returning from main
456+
// drops the tokio runtime, whose drop blocks indefinitely joining that thread, so the
457+
// process would hang instead of exiting (defeating systemd Restart=always when the
458+
// reconnect loop gives up). Exit explicitly so a real exit code reaches the supervisor.
459+
match result {
460+
Ok(()) => std::process::exit(0),
461+
Err(err) => {
462+
tracing::error!(err = %format!("{err:#}"), "exiting");
463+
std::process::exit(1);
464+
}
453465
}
454466
}

0 commit comments

Comments
 (0)