about summary refs log tree commit diff
path: root/src/libstd/sys/windows
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-03-31 14:41:59 -0700
committerAlex Crichton <alex@alexcrichton.com>2015-03-31 14:46:11 -0700
commit71982aa65725a2e630b3abdbb5f48e1abf1acf91 (patch)
treed90f4cf1e4464e949d155cd7e540f3889e287cf3 /src/libstd/sys/windows
parent80bf31dd514055177b22c3dc66836d39eb5b1648 (diff)
downloadrust-71982aa65725a2e630b3abdbb5f48e1abf1acf91.tar.gz
rust-71982aa65725a2e630b3abdbb5f48e1abf1acf91.zip
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
Diffstat (limited to 'src/libstd/sys/windows')
-rw-r--r--src/libstd/sys/windows/c.rs1
-rw-r--r--src/libstd/sys/windows/os.rs4
2 files changed, 5 insertions, 0 deletions
diff --git a/src/libstd/sys/windows/c.rs b/src/libstd/sys/windows/c.rs
index b9be4eb6bf5..b930e35c064 100644
--- a/src/libstd/sys/windows/c.rs
+++ b/src/libstd/sys/windows/c.rs
@@ -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")]
diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs
index 167db1e8ac2..cbbce7f8f0a 100644
--- a/src/libstd/sys/windows/os.rs
+++ b/src/libstd/sys/windows/os.rs
@@ -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) }
+}