Skip to content

Commit

Permalink
Auto merge of #37833 - sfackler:process-abort, r=alexcrichton
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors authored Nov 20, 2016
2 parents 0bd2ce6 + fc0140d commit 7c535c6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/libstd/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,21 @@ pub fn exit(code: i32) -> ! {
::sys::os::exit(code)
}

/// Terminates the process in an abnormal fashion.
///
/// The function will never return and will immediately terminate the current
/// process in a platform specific "abnormal" manner.
///
/// Note that because this function never returns, and that it terminates the
/// process, no destructors on the current stack or any other thread's stack
/// will be run. If a clean shutdown is needed it is recommended to only call
/// this function at a known point where there are no more destructors left
/// to run.
#[unstable(feature = "process_abort", issue = "37838")]
pub fn abort() -> ! {
unsafe { ::sys::abort_internal() };
}

#[cfg(all(test, not(target_os = "emscripten")))]
mod tests {
use io::prelude::*;
Expand Down

0 comments on commit 7c535c6

Please sign in to comment.