about summary refs log tree commit diff
path: root/src/libstd/sys/unix
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2015-02-18 23:50:21 +1100
committerHuon Wilson <dbau.pp+github@gmail.com>2015-02-18 23:50:21 +1100
commitdfc5c0f1e8799f47f9033bdcc8a7cd8a217620a5 (patch)
treee9c32f2e58b3462a23dd9c472d2f236640b78811 /src/libstd/sys/unix
parent6c065fc8cb036785f61ff03e05c1563cbb2dd081 (diff)
parent47f91a9484eceef10536d4caac6ef578cd254567 (diff)
downloadrust-dfc5c0f1e8799f47f9033bdcc8a7cd8a217620a5.tar.gz
rust-dfc5c0f1e8799f47f9033bdcc8a7cd8a217620a5.zip
Manual merge of #22475 - alexcrichton:rollup, r=alexcrichton
 One windows bot failed spuriously.
Diffstat (limited to 'src/libstd/sys/unix')
-rw-r--r--src/libstd/sys/unix/os.rs4
-rw-r--r--src/libstd/sys/unix/thread.rs8
2 files changed, 9 insertions, 3 deletions
diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs
index 8a6ef17818a..df03841276e 100644
--- a/src/libstd/sys/unix/os.rs
+++ b/src/libstd/sys/unix/os.rs
@@ -247,6 +247,10 @@ impl Iterator for Args {
     fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
 }
 
+impl ExactSizeIterator for Args {
+    fn len(&self) -> usize { self.iter.len() }
+}
+
 /// Returns the command line arguments
 ///
 /// Returns a list of the command line arguments.
diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs
index 6f030ee91fe..82c52471d10 100644
--- a/src/libstd/sys/unix/thread.rs
+++ b/src/libstd/sys/unix/thread.rs
@@ -10,6 +10,7 @@
 
 use core::prelude::*;
 
+use io;
 use boxed::Box;
 use cmp;
 use mem;
@@ -191,7 +192,7 @@ pub mod guard {
     }
 }
 
-pub unsafe fn create(stack: uint, p: Thunk) -> rust_thread {
+pub unsafe fn create(stack: uint, p: Thunk) -> io::Result<rust_thread> {
     let mut native: libc::pthread_t = mem::zeroed();
     let mut attr: libc::pthread_attr_t = mem::zeroed();
     assert_eq!(pthread_attr_init(&mut attr), 0);
@@ -226,9 +227,10 @@ pub unsafe fn create(stack: uint, p: Thunk) -> rust_thread {
     if ret != 0 {
         // be sure to not leak the closure
         let _p: Box<Box<FnOnce()+Send>> = mem::transmute(arg);
-        panic!("failed to spawn native thread: {}", ret);
+        Err(io::Error::from_os_error(ret))
+    } else {
+        Ok(native)
     }
-    native
 }
 
 #[cfg(any(target_os = "linux", target_os = "android"))]