Skip to content

Commit

Permalink
Only register the CTRL-C handler when it's safe to do so.
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt committed Jan 4, 2024
1 parent 7f674a2 commit f873b8f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/bin/julialauncher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,6 @@ fn run_app() -> Result<i32> {
}
}

// We set a Ctrl-C handler here that just doesn't do anything, as we want the Julia child
// process to handle things.
ctrlc::set_handler(|| ()).with_context(|| "Failed to set the Ctrl-C handler.")?;

// On *nix platforms we replace the current process with the Julia one.
// This simplifies use in e.g. debuggers, but requires that we fork off
// a subprocess to do the selfupdate and versiondb update.
Expand Down Expand Up @@ -350,6 +346,11 @@ fn run_app() -> Result<i32> {
// any typical daemon-y things (like detaching the TTY)
// so that any error output is still visible.

// We set a Ctrl-C handler here that just doesn't do anything, as we want the Julia child
// process to handle things.
ctrlc::set_handler(|| ())
.with_context(|| "Failed to set the Ctrl-C handler.")?;

run_versiondb_update(&config_file)
.with_context(|| "Failed to run version db update")?;

Expand All @@ -366,6 +367,10 @@ fn run_app() -> Result<i32> {
// On other platforms (i.e., Windows) we just spawn a subprocess
#[cfg(windows)]
{
// We set a Ctrl-C handler here that just doesn't do anything, as we want the Julia child
// process to handle things.
ctrlc::set_handler(|| ()).with_context(|| "Failed to set the Ctrl-C handler.")?;

let mut child_process = std::process::Command::new(julia_path)
.args(&new_args)
.spawn()
Expand Down

0 comments on commit f873b8f

Please sign in to comment.