Revert "Remove unsafe from exit_without_destructors()"

This reverts commit f9c92753c4.

This commit attempted to replace exit_without_destructors() with
std::process::exit; however this is wrong for two reasons:

1. std::process::exit() runs Rust runtime cleanup stuff we don't want
2. std::process::exit() invokes destructors, meaning atexit handlers,
   which we don't want.
This commit is contained in:
ridiculousfish 2023-04-23 15:20:28 -07:00
parent 76dc849fca
commit 009650b7b5

View file

@ -956,11 +956,11 @@ pub const fn char_offset(base: char, offset: u32) -> char {
}
}
/// Exits without invoking destructors; useful for forked processes.
///
/// [`std::process::exit()`] is used; it exits immediately without running any destructors.
/// Exits without invoking destructors (via _exit), useful for code after fork.
fn exit_without_destructors(code: i32) -> ! {
std::process::exit(code)
unsafe {
libc::_exit(code);
}
}
/// Save the shell mode on startup so we can restore them on exit.