diff options
| author | Dan Gohman <dev@sunfishcode.online> | 2021-10-05 14:11:49 -0700 |
|---|---|---|
| committer | Dan Gohman <dev@sunfishcode.online> | 2021-10-05 14:13:07 -0700 |
| commit | 53e072f2207747e8b60dcbb77b763c1598cfb192 (patch) | |
| tree | 35791ed38c5d4e38e1882e6412be2d225402a7d9 /library/std/src | |
| parent | 2d6a4c85ca037ac07cac6029c2b174678c39a40d (diff) | |
| download | rust-53e072f2207747e8b60dcbb77b763c1598cfb192.tar.gz rust-53e072f2207747e8b60dcbb77b763c1598cfb192.zip | |
Fix compilation on WASI, which doesn't yet support `dup`.
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/os/fd/owned.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/library/std/src/os/fd/owned.rs b/library/std/src/os/fd/owned.rs index 597e050b00d..0b6588db92c 100644 --- a/library/std/src/os/fd/owned.rs +++ b/library/std/src/os/fd/owned.rs @@ -8,6 +8,7 @@ use crate::fmt; use crate::fs; use crate::marker::PhantomData; use crate::mem::forget; +#[cfg(not(target_os = "wasi"))] use crate::sys::cvt; use crate::sys_common::{AsInner, FromInner, IntoInner}; @@ -71,6 +72,7 @@ impl BorrowedFd<'_> { impl OwnedFd { /// Creates a new `OwnedFd` instance that shares the same underlying file handle /// as the existing `OwnedFd` instance. + #[cfg(not(target_os = "wasi"))] pub fn try_clone(&self) -> crate::io::Result<Self> { // We want to atomically duplicate this file descriptor and set the // CLOEXEC flag, and currently that's done via F_DUPFD_CLOEXEC. This @@ -88,6 +90,14 @@ impl OwnedFd { let fd = cvt(unsafe { libc::fcntl(self.as_raw_fd(), cmd, 0) })?; Ok(unsafe { Self::from_raw_fd(fd) }) } + + #[cfg(target_os = "wasi")] + pub fn try_clone(&self) -> crate::io::Result<Self> { + Err(crate::io::Error::new_const( + crate::io::ErrorKind::Unsupported, + &"operation not supported on WASI yet", + )) + } } #[unstable(feature = "io_safety", issue = "87074")] |
