Haiku: Work around the lack of the FIOCLEX ioctl

* Hand rebased from Niels original work on 1.9.0
This commit is contained in:
Niels Sascha Reedijk 2016-09-24 23:41:29 -05:00 committed by Alexander von Gluck IV
parent 1a6fc8b7b8
commit 783ab7766f

View file

@ -59,14 +59,20 @@ impl FileDesc {
Ok(ret as usize) Ok(ret as usize)
} }
#[cfg(not(any(target_env = "newlib", target_os = "solaris", target_os = "emscripten")))] #[cfg(not(any(target_env = "newlib",
target_os = "solaris",
target_os = "emscripten",
target_os = "haiku")))]
pub fn set_cloexec(&self) -> io::Result<()> { pub fn set_cloexec(&self) -> io::Result<()> {
unsafe { unsafe {
cvt(libc::ioctl(self.fd, libc::FIOCLEX))?; cvt(libc::ioctl(self.fd, libc::FIOCLEX))?;
Ok(()) Ok(())
} }
} }
#[cfg(any(target_env = "newlib", target_os = "solaris", target_os = "emscripten"))] #[cfg(any(target_env = "newlib",
target_os = "solaris",
target_os = "emscripten",
target_os = "haiku"))]
pub fn set_cloexec(&self) -> io::Result<()> { pub fn set_cloexec(&self) -> io::Result<()> {
unsafe { unsafe {
let previous = cvt(libc::fcntl(self.fd, libc::F_GETFD))?; let previous = cvt(libc::fcntl(self.fd, libc::F_GETFD))?;