Skip to content

Commit e7f734e

Browse files
committed
---
yaml --- r: 88838 b: refs/heads/snap-stage3 c: daaec28 h: refs/heads/master v: v3
1 parent 7d0329c commit e7f734e

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: deeca5d586bfaa4aa60246f671a8d611d38f6248
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 429313de69cb2ddd1f076017968d1862ef02b455
4+
refs/heads/snap-stage3: daaec28c6f71f5d6e2f5bc716ffc2780ef56fa7b
55
refs/heads/try: b160761e35efcd1207112b3b782c06633cf441a8
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libstd/os.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828

2929
#[allow(missing_doc)];
3030

31-
#[cfg(unix)]
32-
use c_str::CString;
3331
use clone::Clone;
3432
use container::Container;
3533
#[cfg(target_os = "macos")]
@@ -43,6 +41,7 @@ use ptr;
4341
use str;
4442
use to_str;
4543
use unstable::finally::Finally;
44+
use sync::atomics::{AtomicInt, INIT_ATOMIC_INT, SeqCst};
4645

4746
pub use os::consts::*;
4847

@@ -58,6 +57,8 @@ static BUF_BYTES : uint = 2048u;
5857

5958
#[cfg(unix)]
6059
pub fn getcwd() -> Path {
60+
use c_str::CString;
61+
6162
let mut buf = [0 as libc::c_char, ..BUF_BYTES];
6263
unsafe {
6364
if libc::getcwd(buf.as_mut_ptr(), buf.len() as size_t).is_null() {
@@ -675,17 +676,26 @@ pub fn last_os_error() -> ~str {
675676
strerror()
676677
}
677678

679+
static mut EXIT_STATUS: AtomicInt = INIT_ATOMIC_INT;
680+
678681
/**
679682
* Sets the process exit code
680683
*
681684
* Sets the exit code returned by the process if all supervised tasks
682685
* terminate successfully (without failing). If the current root task fails
683686
* and is supervised by the scheduler then any user-specified exit status is
684-
* ignored and the process exits with the default failure status
687+
* ignored and the process exits with the default failure status.
688+
*
689+
* Note that this is not synchronized against modifications of other threads.
685690
*/
686691
pub fn set_exit_status(code: int) {
687-
use rt;
688-
rt::set_exit_status(code);
692+
unsafe { EXIT_STATUS.store(code, SeqCst) }
693+
}
694+
695+
/// Fetches the process's current exit code. This defaults to 0 and can change
696+
/// by calling `set_exit_status`.
697+
pub fn get_exit_status() -> int {
698+
unsafe { EXIT_STATUS.load(SeqCst) }
689699
}
690700

691701
#[cfg(target_os = "macos")]

0 commit comments

Comments
 (0)