Skip to content

Commit 7a1dc76

Browse files
committed
core: Move set_exit_status from sys to os
1 parent 1cad632 commit 7a1dc76

File tree

5 files changed

+16
-17
lines changed

5 files changed

+16
-17
lines changed

src/libcore/os.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export homedir, list_dir, list_dir_path, path_is_dir, path_exists,
3333
make_absolute, make_dir, remove_dir, change_dir, remove_file,
3434
copy_file;
3535
export last_os_error;
36+
export set_exit_status;
3637

3738
// FIXME: move these to str perhaps?
3839
export as_c_charp, fill_charp_buf;
@@ -45,6 +46,7 @@ native mod rustrt {
4546
fn rust_list_files(path: str) -> [str];
4647
fn rust_process_wait(handle: c_int) -> c_int;
4748
fn last_os_error() -> str;
49+
fn rust_set_exit_status(code: libc::intptr_t);
4850
}
4951

5052

@@ -630,6 +632,17 @@ fn last_os_error() -> str {
630632
rustrt::last_os_error()
631633
}
632634

635+
#[doc = "
636+
Sets the process exit code
637+
638+
Sets the exit code returned by the process if all supervised tasks terminate
639+
successfully (without failing). If the current root task fails and is
640+
supervised by the scheduler then any user-specified exit status is ignored and
641+
the process exits with the default failure status
642+
"]
643+
fn set_exit_status(code: int) {
644+
rustrt::rust_set_exit_status(code as libc::intptr_t);
645+
}
633646

634647
#[cfg(target_os = "macos")]
635648
mod consts {

src/libcore/sys.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export size_of;
66
export align_of;
77
export refcount;
88
export log_str;
9-
export set_exit_status;
109

1110
enum type_desc = {
1211
first_param: **libc::c_int,
@@ -20,7 +19,6 @@ native mod rustrt {
2019
fn refcount<T>(t: @T) -> libc::intptr_t;
2120
fn unsupervise();
2221
fn shape_log_str<T>(t: *sys::type_desc, data: T) -> str;
23-
fn rust_set_exit_status(code: libc::intptr_t);
2422
}
2523

2624
#[abi = "rust-intrinsic"]
@@ -59,18 +57,6 @@ fn log_str<T>(t: T) -> str {
5957
rustrt::shape_log_str(get_type_desc::<T>(), t)
6058
}
6159

62-
#[doc = "
63-
Sets the process exit code
64-
65-
Sets the exit code returned by the process if all supervised tasks terminate
66-
successfully (without failing). If the current root task fails and is
67-
supervised by the scheduler then any user-specified exit status is ignored and
68-
the process exits with the default failure status
69-
"]
70-
fn set_exit_status(code: int) {
71-
rustrt::rust_set_exit_status(code as libc::intptr_t);
72-
}
73-
7460
#[cfg(test)]
7561
mod tests {
7662

src/test/run-fail/rt-set-exit-status-fail.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ fn main() {
55
// Setting the exit status only works when the scheduler terminates
66
// normally. In this case we're going to fail, so instead of of
77
// returning 50 the process will return the typical rt failure code.
8-
sys::set_exit_status(50);
8+
os::set_exit_status(50);
99
fail;
1010
}

src/test/run-fail/rt-set-exit-status-fail2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn main() {
77
// Setting the exit status after the runtime has already
88
// failed has no effect and the process exits with the
99
// runtime's exit code
10-
sys::set_exit_status(50);
10+
os::set_exit_status(50);
1111
}
1212
let i = r(());
1313
};

src/test/run-fail/rt-set-exit-status.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ fn main() {
44
log(error, "whatever");
55
// 101 is the code the runtime uses on task failure and the value
66
// compiletest expects run-fail tests to return.
7-
sys::set_exit_status(101);
7+
os::set_exit_status(101);
88
}

0 commit comments

Comments
 (0)