File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments