Skip to content

Commit fc0140d

Browse files
committed
Add std::process::abort
This calls libc abort on Unix and fastfail on Windows.
1 parent 5bd1e7f commit fc0140d

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)