Add option to disable crash handler (#40799)
Extra info needed for #39289. To be tested out next nightly build... Release Notes: - N/A Co-authored-by: Cole Miller <m@cole-miller.net>
This commit is contained in:
@@ -33,17 +33,31 @@ const CRASH_HANDLER_CONNECT_TIMEOUT: Duration = Duration::from_secs(10);
|
|||||||
static PANIC_THREAD_ID: AtomicU32 = AtomicU32::new(0);
|
static PANIC_THREAD_ID: AtomicU32 = AtomicU32::new(0);
|
||||||
|
|
||||||
pub async fn init(crash_init: InitCrashHandler) {
|
pub async fn init(crash_init: InitCrashHandler) {
|
||||||
if *RELEASE_CHANNEL == ReleaseChannel::Dev && env::var("ZED_GENERATE_MINIDUMPS").is_err() {
|
let gen_var = match env::var("ZED_GENERATE_MINIDUMPS") {
|
||||||
let old_hook = panic::take_hook();
|
Ok(v) => {
|
||||||
panic::set_hook(Box::new(move |info| {
|
if v == "false" || v == "0" {
|
||||||
unsafe { env::set_var("RUST_BACKTRACE", "1") };
|
Some(false)
|
||||||
old_hook(info);
|
} else {
|
||||||
// prevent the macOS crash dialog from popping up
|
Some(true)
|
||||||
std::process::exit(1);
|
}
|
||||||
}));
|
}
|
||||||
return;
|
Err(_) => None,
|
||||||
} else {
|
};
|
||||||
panic::set_hook(Box::new(panic_hook));
|
|
||||||
|
match (gen_var, *RELEASE_CHANNEL) {
|
||||||
|
(Some(false), _) | (None, ReleaseChannel::Dev) => {
|
||||||
|
let old_hook = panic::take_hook();
|
||||||
|
panic::set_hook(Box::new(move |info| {
|
||||||
|
unsafe { env::set_var("RUST_BACKTRACE", "1") };
|
||||||
|
old_hook(info);
|
||||||
|
// prevent the macOS crash dialog from popping up
|
||||||
|
std::process::exit(1);
|
||||||
|
}));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
(Some(true), _) | (None, _) => {
|
||||||
|
panic::set_hook(Box::new(panic_hook));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let exe = env::current_exe().expect("unable to find ourselves");
|
let exe = env::current_exe().expect("unable to find ourselves");
|
||||||
|
|||||||
Reference in New Issue
Block a user