提交 7a1dc76b 编写于 作者: B Brian Anderson

core: Move set_exit_status from sys to os

上级 1cad6322
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
make_absolute, make_dir, remove_dir, change_dir, remove_file, make_absolute, make_dir, remove_dir, change_dir, remove_file,
copy_file; copy_file;
export last_os_error; export last_os_error;
export set_exit_status;
// FIXME: move these to str perhaps? // FIXME: move these to str perhaps?
export as_c_charp, fill_charp_buf; export as_c_charp, fill_charp_buf;
...@@ -45,6 +46,7 @@ ...@@ -45,6 +46,7 @@
fn rust_list_files(path: str) -> [str]; fn rust_list_files(path: str) -> [str];
fn rust_process_wait(handle: c_int) -> c_int; fn rust_process_wait(handle: c_int) -> c_int;
fn last_os_error() -> str; fn last_os_error() -> str;
fn rust_set_exit_status(code: libc::intptr_t);
} }
...@@ -630,6 +632,17 @@ fn last_os_error() -> str { ...@@ -630,6 +632,17 @@ fn last_os_error() -> str {
rustrt::last_os_error() rustrt::last_os_error()
} }
#[doc = "
Sets the process exit code
Sets the exit code returned by the process if all supervised tasks terminate
successfully (without failing). If the current root task fails and is
supervised by the scheduler then any user-specified exit status is ignored and
the process exits with the default failure status
"]
fn set_exit_status(code: int) {
rustrt::rust_set_exit_status(code as libc::intptr_t);
}
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
mod consts { mod consts {
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
export align_of; export align_of;
export refcount; export refcount;
export log_str; export log_str;
export set_exit_status;
enum type_desc = { enum type_desc = {
first_param: **libc::c_int, first_param: **libc::c_int,
...@@ -20,7 +19,6 @@ enum type_desc = { ...@@ -20,7 +19,6 @@ enum type_desc = {
fn refcount<T>(t: @T) -> libc::intptr_t; fn refcount<T>(t: @T) -> libc::intptr_t;
fn unsupervise(); fn unsupervise();
fn shape_log_str<T>(t: *sys::type_desc, data: T) -> str; fn shape_log_str<T>(t: *sys::type_desc, data: T) -> str;
fn rust_set_exit_status(code: libc::intptr_t);
} }
#[abi = "rust-intrinsic"] #[abi = "rust-intrinsic"]
...@@ -59,18 +57,6 @@ fn log_str<T>(t: T) -> str { ...@@ -59,18 +57,6 @@ fn log_str<T>(t: T) -> str {
rustrt::shape_log_str(get_type_desc::<T>(), t) rustrt::shape_log_str(get_type_desc::<T>(), t)
} }
#[doc = "
Sets the process exit code
Sets the exit code returned by the process if all supervised tasks terminate
successfully (without failing). If the current root task fails and is
supervised by the scheduler then any user-specified exit status is ignored and
the process exits with the default failure status
"]
fn set_exit_status(code: int) {
rustrt::rust_set_exit_status(code as libc::intptr_t);
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
......
...@@ -5,6 +5,6 @@ fn main() { ...@@ -5,6 +5,6 @@ fn main() {
// Setting the exit status only works when the scheduler terminates // Setting the exit status only works when the scheduler terminates
// normally. In this case we're going to fail, so instead of of // normally. In this case we're going to fail, so instead of of
// returning 50 the process will return the typical rt failure code. // returning 50 the process will return the typical rt failure code.
sys::set_exit_status(50); os::set_exit_status(50);
fail; fail;
} }
\ No newline at end of file
...@@ -7,7 +7,7 @@ fn main() { ...@@ -7,7 +7,7 @@ fn main() {
// Setting the exit status after the runtime has already // Setting the exit status after the runtime has already
// failed has no effect and the process exits with the // failed has no effect and the process exits with the
// runtime's exit code // runtime's exit code
sys::set_exit_status(50); os::set_exit_status(50);
} }
let i = r(()); let i = r(());
}; };
......
...@@ -4,5 +4,5 @@ fn main() { ...@@ -4,5 +4,5 @@ fn main() {
log(error, "whatever"); log(error, "whatever");
// 101 is the code the runtime uses on task failure and the value // 101 is the code the runtime uses on task failure and the value
// compiletest expects run-fail tests to return. // compiletest expects run-fail tests to return.
sys::set_exit_status(101); os::set_exit_status(101);
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册