about summary refs log tree commit diff
path: root/src/libnative/io/process.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-01-03 23:49:56 -0800
committerAlex Crichton <alex@alexcrichton.com>2014-01-05 09:19:40 -0800
commit674d24e2e6fad26fc4cedc2fe935ade63198ba7e (patch)
treee6468e6d917a5bfc19a315890ec23dc5e043566e /src/libnative/io/process.rs
parenta1cb8dc30c6adc88703763a8703b6a3027598b2d (diff)
downloadrust-674d24e2e6fad26fc4cedc2fe935ade63198ba7e.tar.gz
rust-674d24e2e6fad26fc4cedc2fe935ade63198ba7e.zip
Handle EINTR throughout libnative
Closes #11214
Diffstat (limited to 'src/libnative/io/process.rs')
-rw-r--r--src/libnative/io/process.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/libnative/io/process.rs b/src/libnative/io/process.rs
index 3fda4486921..0569c45f6de 100644
--- a/src/libnative/io/process.rs
+++ b/src/libnative/io/process.rs
@@ -16,11 +16,12 @@ use std::ptr;
 use std::rt::rtio;
 use p = std::io::process;
 
-#[cfg(windows)] use std::cast;
-
 use super::IoResult;
 use super::file;
 
+#[cfg(windows)] use std::cast;
+#[cfg(not(windows))] use super::retry;
+
 /**
  * A value representing a child process.
  *
@@ -445,17 +446,17 @@ fn spawn_process_os(prog: &str, args: &[~str],
 
         if in_fd == -1 {
             libc::close(libc::STDIN_FILENO);
-        } else if dup2(in_fd, 0) == -1 {
+        } else if retry(|| dup2(in_fd, 0)) == -1 {
             fail!("failure in dup2(in_fd, 0): {}", os::last_os_error());
         }
         if out_fd == -1 {
             libc::close(libc::STDOUT_FILENO);
-        } else if dup2(out_fd, 1) == -1 {
+        } else if retry(|| dup2(out_fd, 1)) == -1 {
             fail!("failure in dup2(out_fd, 1): {}", os::last_os_error());
         }
         if err_fd == -1 {
             libc::close(libc::STDERR_FILENO);
-        } else if dup2(err_fd, 2) == -1 {
+        } else if retry(|| dup2(err_fd, 2)) == -1 {
             fail!("failure in dup3(err_fd, 2): {}", os::last_os_error());
         }
         // close all other fds
@@ -664,9 +665,9 @@ fn waitpid(pid: pid_t) -> p::ProcessExit {
         }
 
         let mut status = 0 as c_int;
-        match super::retry(|| unsafe { wait::waitpid(pid, &mut status, 0) }) {
-            Err(e) => fail!("unknown waitpid error: {:?}", e),
-            Ok(_ret) => {
+        match retry(|| unsafe { wait::waitpid(pid, &mut status, 0) }) {
+            -1 => fail!("unknown waitpid error: {:?}", super::last_error()),
+            _ => {
                 if imp::WIFEXITED(status) {
                     p::ExitStatus(imp::WEXITSTATUS(status) as int)
                 } else {