diff options
| author | bors <bors@rust-lang.org> | 2024-05-25 22:26:32 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-05-25 22:26:32 +0000 |
| commit | 0a59f113629aafb6e5ee55ad04a2d451a11d8466 (patch) | |
| tree | 186a3505f2133d75d317f3cb342c61bd0511edaa /compiler/rustc_driver_impl/src/lib.rs | |
| parent | 1ba35e9bb44d416fc2ebf897855454258b650b01 (diff) | |
| parent | 0ded36f729b6fb9fb110692f6725e27f3bf739b0 (diff) | |
| download | rust-0a59f113629aafb6e5ee55ad04a2d451a11d8466.tar.gz rust-0a59f113629aafb6e5ee55ad04a2d451a11d8466.zip | |
Auto merge of #125552 - matthiaskrgr:rollup-f1yybpn, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #121377 (Stabilize `LazyCell` and `LazyLock`) - #122986 (Fix c_char on AIX) - #123803 (Fix `VecDeque::shrink_to` UB when `handle_alloc_error` unwinds.) - #124080 (Some unstable changes to where opaque types get defined) - #124667 (Stabilize `div_duration`) - #125472 (tidy: validate LLVM component names in tests) - #125523 (Exit the process a short time after entering our ctrl-c handler) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_driver_impl/src/lib.rs')
| -rw-r--r-- | compiler/rustc_driver_impl/src/lib.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 5532eff7be6..2bd58680eef 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -57,7 +57,7 @@ use std::process::{self, Command, Stdio}; use std::str; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, OnceLock}; -use std::time::{Instant, SystemTime}; +use std::time::{Duration, Instant, SystemTime}; use time::OffsetDateTime; use tracing::trace; @@ -1502,14 +1502,13 @@ pub fn init_logger(early_dcx: &EarlyDiagCtxt, cfg: rustc_log::LoggerConfig) { pub fn install_ctrlc_handler() { #[cfg(not(target_family = "wasm"))] ctrlc::set_handler(move || { - // Indicate that we have been signaled to stop. If we were already signaled, exit - // immediately. In our interpreter loop we try to consult this value often, but if for - // whatever reason we don't get to that check or the cleanup we do upon finding that - // this bool has become true takes a long time, the exit here will promptly exit the - // process on the second Ctrl-C. - if CTRL_C_RECEIVED.swap(true, Ordering::Relaxed) { - std::process::exit(1); - } + // Indicate that we have been signaled to stop, then give the rest of the compiler a bit of + // time to check CTRL_C_RECEIVED and run its own shutdown logic, but after a short amount + // of time exit the process. This sleep+exit ensures that even if nobody is checking + // CTRL_C_RECEIVED, the compiler exits reasonably promptly. + CTRL_C_RECEIVED.store(true, Ordering::Relaxed); + std::thread::sleep(Duration::from_millis(100)); + std::process::exit(1); }) .expect("Unable to install ctrlc handler"); } |
