Skip to content

Commit 48cef14

Browse files
committed
spawns task to ignore sigint in parent process when spawning chat
1 parent aa146bf commit 48cef14

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
@@ -63,6 +63,7 @@ use fig_util::{
6363
};
6464
use internal::InternalSubcommand;
6565
use serde::Serialize;
66+
use tokio::signal::ctrl_c;
6667
use tracing::{
6768
Level,
6869
debug,
@@ -351,9 +352,20 @@ impl Cli {
351352
cmd.args(args);
352353
}
353354

354-
cmd.status().await?;
355+
// Because we are spawning chat as a child process, we need the parent process (this one)
356+
// to ignore sigint that are meant for chat (i.e. all of them)
357+
tokio::spawn(async move {
358+
loop {
359+
let _ = ctrl_c().await;
360+
}
361+
});
355362

356-
Ok(ExitCode::SUCCESS)
363+
let exit_status = cmd.status().await?;
364+
let exit_code = exit_status
365+
.code()
366+
.map_or(ExitCode::FAILURE, |e| ExitCode::from(e as u8));
367+
368+
Ok(exit_code)
357369
}
358370

359371
async fn send_telemetry(&self) {

0 commit comments

Comments
 (0)