Skip to content

Commit 5efdafa

Browse files
committed
---
yaml --- r: 147454 b: refs/heads/try2 c: daaec28 h: refs/heads/master v: v3
1 parent db41dfc commit 5efdafa

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
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 429313de69cb2ddd1f076017968d1862ef02b455
8+
refs/heads/try2: daaec28c6f71f5d6e2f5bc716ffc2780ef56fa7b
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/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)