std: Add a process::exit function
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
This commit is contained in:
@@ -505,3 +505,7 @@ pub fn home_dir() -> Option<PathBuf> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn exit(code: i32) -> ! {
|
||||
unsafe { libc::exit(code as c_int) }
|
||||
}
|
||||
|
||||
@@ -433,6 +433,7 @@ extern "system" {
|
||||
TokenHandle: *mut libc::HANDLE) -> libc::BOOL;
|
||||
pub fn GetCurrentProcess() -> libc::HANDLE;
|
||||
pub fn GetStdHandle(which: libc::DWORD) -> libc::HANDLE;
|
||||
pub fn ExitProcess(uExitCode: libc::UINT) -> !;
|
||||
}
|
||||
|
||||
#[link(name = "userenv")]
|
||||
|
||||
@@ -379,3 +379,7 @@ pub fn home_dir() -> Option<PathBuf> {
|
||||
}, super::os2path).ok()
|
||||
})
|
||||
}
|
||||
|
||||
pub fn exit(code: i32) -> ! {
|
||||
unsafe { libc::ExitProcess(code as libc::UINT) }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user