Skip to content

Commit 9a932d1

Browse files
authored
fix: spawns task to ignore sigint in parent process when spawning chat (#1794)
1 parent ec6fa9c commit 9a932d1

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

crates/q_cli/src/cli/mod.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ use fig_util::{
6666
};
6767
use internal::InternalSubcommand;
6868
use serde::Serialize;
69+
use tokio::signal::ctrl_c;
6970
use tracing::{
7071
Level,
7172
debug,
@@ -367,9 +368,20 @@ impl Cli {
367368
cmd.args(args);
368369
}
369370

370-
cmd.status().await?;
371+
// Because we are spawning chat as a child process, we need the parent process (this one)
372+
// to ignore sigint that are meant for chat (i.e. all of them)
373+
tokio::spawn(async move {
374+
loop {
375+
let _ = ctrl_c().await;
376+
}
377+
});
371378

372-
Ok(ExitCode::SUCCESS)
379+
let exit_status = cmd.status().await?;
380+
let exit_code = exit_status
381+
.code()
382+
.map_or(ExitCode::FAILURE, |e| ExitCode::from(e as u8));
383+
384+
Ok(exit_code)
373385
}
374386

375387
async fn send_telemetry(&self) {

0 commit comments

Comments
 (0)