about summary refs log tree commit diff
path: root/src/libstd/sys
diff options
context:
space:
mode:
authorTobias Bucher <tobiasbucher5991@gmail.com>2017-01-30 17:37:49 +0100
committerTobias Bucher <tobiasbucher5991@gmail.com>2017-01-30 17:37:49 +0100
commit4b46d2a3a222f090b07b019df0e9346b08c40ae1 (patch)
treefa6b6dc2fb2918de3b881a0ea67bd86cd9e968a1 /src/libstd/sys
parentc31d5b504144c4c542c3042b850cfc3b1066aa38 (diff)
downloadrust-4b46d2a3a222f090b07b019df0e9346b08c40ae1.tar.gz
rust-4b46d2a3a222f090b07b019df0e9346b08c40ae1.zip
Don't handle ENOSYS in `anon_pipe()`
We're not calling the raw syscall but a libc function, the libc will
have a compatibility layer.
Diffstat (limited to 'src/libstd/sys')
-rw-r--r--src/libstd/sys/unix/pipe.rs23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/libstd/sys/unix/pipe.rs b/src/libstd/sys/unix/pipe.rs
index a5d60c257ed..51e00fc1ab9 100644
--- a/src/libstd/sys/unix/pipe.rs
+++ b/src/libstd/sys/unix/pipe.rs
@@ -13,7 +13,6 @@ use io;
 use libc::{self, c_int};
 use mem;
 use ptr;
-use sync::atomic::{AtomicBool, Ordering};
 use sys::{cvt, cvt_r};
 use sys::fd::FileDesc;
 
@@ -30,21 +29,17 @@ pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> {
     // CLOEXEC flag is to use the `pipe2` syscall on Linux. This was added in
     // 2.6.27, however, and because we support 2.6.18 we must detect this
     // support dynamically.
-    static TRY_PIPE2: AtomicBool = AtomicBool::new(cfg!(target_os = "linux"));
-    if TRY_PIPE2.load(Ordering::Relaxed) {
+    if cfg!(any(target_os = "dragonfly",
+                target_os = "freebsd",
+                target_os = "linux",
+                target_os = "netbsd",
+                target_os = "openbsd"))
+    {
         weak! { fn pipe2(*mut c_int, c_int) -> c_int }
         if let Some(pipe) = pipe2.get() {
-            match cvt(unsafe { pipe(fds.as_mut_ptr(), libc::O_CLOEXEC) }) {
-                Err(ref e) if e.raw_os_error() == Some(libc::ENOSYS) => {
-                    TRY_PIPE2.store(false, Ordering::Relaxed);
-                    // Fall through
-                },
-                res => {
-                    res?;
-                    return Ok((AnonPipe(FileDesc::new(fds[0])),
-                               AnonPipe(FileDesc::new(fds[1]))));
-                }
-            }
+            cvt(unsafe { pipe(fds.as_mut_ptr(), libc::O_CLOEXEC) })?;
+            return Ok((AnonPipe(FileDesc::new(fds[0])),
+                       AnonPipe(FileDesc::new(fds[1]))));
         }
     }
     cvt(unsafe { libc::pipe(fds.as_mut_ptr()) })?;