Skip to content

Commit 7c535c6

Browse files
authored
Auto merge of #37833 - sfackler:process-abort, r=alexcrichton
Add std::process::abort This calls libc abort on Unix and fastfail on Windows, first running cleanups to do things like flush stdout buffers. This matches with libc abort's behavior, which flushes open files. r? @alexcrichton
2 parents 0bd2ce6 + fc0140d commit 7c535c6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/libstd/process.rs

+15
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,21 @@ pub fn exit(code: i32) -> ! {
825825
::sys::os::exit(code)
826826
}
827827

828+
/// Terminates the process in an abnormal fashion.
829+
///
830+
/// The function will never return and will immediately terminate the current
831+
/// process in a platform specific "abnormal" manner.
832+
///
833+
/// Note that because this function never returns, and that it terminates the
834+
/// process, no destructors on the current stack or any other thread's stack
835+
/// will be run. If a clean shutdown is needed it is recommended to only call
836+
/// this function at a known point where there are no more destructors left
837+
/// to run.
838+
#[unstable(feature = "process_abort", issue = "37838")]
839+
pub fn abort() -> ! {
840+
unsafe { ::sys::abort_internal() };
841+
}
842+
828843
#[cfg(all(test, not(target_os = "emscripten")))]
829844
mod tests {
830845
use io::prelude::*;

0 commit comments

Comments
 (0)