diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-03-31 15:58:57 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-03-31 15:58:57 -0700 |
| commit | a37311d486d5e71b2f2d1290c9f9228c4f6ead79 (patch) | |
| tree | 21beece7faab89e01f8c58cf92f78ab0002fe4d1 /src/libstd/process.rs | |
| parent | 0cac5b615811afeb634a73b86dcf0f1f51fe9aa8 (diff) | |
| parent | 71982aa65725a2e630b3abdbb5f48e1abf1acf91 (diff) | |
rollup merge of #23907: alexcrichton/impl-exit
This commit is an implementation of [RFC #1011][rfc] which adds an `exit` function to the standard library for immediately terminating the current process with a specified exit code. [rfc]: https://github.com/rust-lang/rfcs/pull/1011 Closes #23914
Diffstat (limited to 'src/libstd/process.rs')
| -rw-r--r-- | src/libstd/process.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libstd/process.rs b/src/libstd/process.rs index ece0aa8f064..63023855514 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -522,6 +522,22 @@ impl Child { } } +/// Terminates the current process with the specified exit code. +/// +/// This function will never return and will immediately terminate the current +/// process. The exit code is passed through to the underlying OS and will be +/// available for consumption by another process. +/// +/// 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. +#[stable(feature = "rust1", since = "1.0.0")] +pub fn exit(code: i32) -> ! { + ::sys::os::exit(code) +} + #[cfg(test)] mod tests { use prelude::v1::*; |
