Skip to content

Commit 4b46d2a

Browse files
committed
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.
1 parent c31d5b5 commit 4b46d2a

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

Diff for: src/libstd/sys/unix/pipe.rs

+9-14
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use io;
1313
use libc::{self, c_int};
1414
use mem;
1515
use ptr;
16-
use sync::atomic::{AtomicBool, Ordering};
1716
use sys::{cvt, cvt_r};
1817
use sys::fd::FileDesc;
1918

@@ -30,21 +29,17 @@ pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> {
3029
// CLOEXEC flag is to use the `pipe2` syscall on Linux. This was added in
3130
// 2.6.27, however, and because we support 2.6.18 we must detect this
3231
// support dynamically.
33-
static TRY_PIPE2: AtomicBool = AtomicBool::new(cfg!(target_os = "linux"));
34-
if TRY_PIPE2.load(Ordering::Relaxed) {
32+
if cfg!(any(target_os = "dragonfly",
33+
target_os = "freebsd",
34+
target_os = "linux",
35+
target_os = "netbsd",
36+
target_os = "openbsd"))
37+
{
3538
weak! { fn pipe2(*mut c_int, c_int) -> c_int }
3639
if let Some(pipe) = pipe2.get() {
37-
match cvt(unsafe { pipe(fds.as_mut_ptr(), libc::O_CLOEXEC) }) {
38-
Err(ref e) if e.raw_os_error() == Some(libc::ENOSYS) => {
39-
TRY_PIPE2.store(false, Ordering::Relaxed);
40-
// Fall through
41-
},
42-
res => {
43-
res?;
44-
return Ok((AnonPipe(FileDesc::new(fds[0])),
45-
AnonPipe(FileDesc::new(fds[1]))));
46-
}
47-
}
40+
cvt(unsafe { pipe(fds.as_mut_ptr(), libc::O_CLOEXEC) })?;
41+
return Ok((AnonPipe(FileDesc::new(fds[0])),
42+
AnonPipe(FileDesc::new(fds[1]))));
4843
}
4944
}
5045
cvt(unsafe { libc::pipe(fds.as_mut_ptr()) })?;

0 commit comments

Comments
 (0)