core: Move set_exit_status from sys to os
This commit is contained in:
parent
1cad6322c3
commit
7a1dc76b0f
@ -33,6 +33,7 @@ export homedir, list_dir, list_dir_path, path_is_dir, path_exists,
|
||||
make_absolute, make_dir, remove_dir, change_dir, remove_file,
|
||||
copy_file;
|
||||
export last_os_error;
|
||||
export set_exit_status;
|
||||
|
||||
// FIXME: move these to str perhaps?
|
||||
export as_c_charp, fill_charp_buf;
|
||||
@ -45,6 +46,7 @@ native mod rustrt {
|
||||
fn rust_list_files(path: str) -> [str];
|
||||
fn rust_process_wait(handle: c_int) -> c_int;
|
||||
fn last_os_error() -> str;
|
||||
fn rust_set_exit_status(code: libc::intptr_t);
|
||||
}
|
||||
|
||||
|
||||
@ -630,6 +632,17 @@ fn last_os_error() -> str {
|
||||
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")]
|
||||
mod consts {
|
||||
|
@ -6,7 +6,6 @@ export size_of;
|
||||
export align_of;
|
||||
export refcount;
|
||||
export log_str;
|
||||
export set_exit_status;
|
||||
|
||||
enum type_desc = {
|
||||
first_param: **libc::c_int,
|
||||
@ -20,7 +19,6 @@ native mod rustrt {
|
||||
fn refcount<T>(t: @T) -> libc::intptr_t;
|
||||
fn unsupervise();
|
||||
fn shape_log_str<T>(t: *sys::type_desc, data: T) -> str;
|
||||
fn rust_set_exit_status(code: libc::intptr_t);
|
||||
}
|
||||
|
||||
#[abi = "rust-intrinsic"]
|
||||
@ -59,18 +57,6 @@ fn log_str<T>(t: T) -> str {
|
||||
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)]
|
||||
mod tests {
|
||||
|
||||
|
@ -5,6 +5,6 @@ fn main() {
|
||||
// Setting the exit status only works when the scheduler terminates
|
||||
// normally. In this case we're going to fail, so instead of of
|
||||
// returning 50 the process will return the typical rt failure code.
|
||||
sys::set_exit_status(50);
|
||||
os::set_exit_status(50);
|
||||
fail;
|
||||
}
|
@ -7,7 +7,7 @@ fn main() {
|
||||
// Setting the exit status after the runtime has already
|
||||
// failed has no effect and the process exits with the
|
||||
// runtime's exit code
|
||||
sys::set_exit_status(50);
|
||||
os::set_exit_status(50);
|
||||
}
|
||||
let i = r(());
|
||||
};
|
||||
|
@ -4,5 +4,5 @@ fn main() {
|
||||
log(error, "whatever");
|
||||
// 101 is the code the runtime uses on task failure and the value
|
||||
// compiletest expects run-fail tests to return.
|
||||
sys::set_exit_status(101);
|
||||
os::set_exit_status(101);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user