Skip to content

Commit 53e072f

Browse files
committed
Fix compilation on WASI, which doesn't yet support dup.
1 parent 2d6a4c8 commit 53e072f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

library/std/src/os/fd/owned.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::fmt;
88
use crate::fs;
99
use crate::marker::PhantomData;
1010
use crate::mem::forget;
11+
#[cfg(not(target_os = "wasi"))]
1112
use crate::sys::cvt;
1213
use crate::sys_common::{AsInner, FromInner, IntoInner};
1314

@@ -71,6 +72,7 @@ impl BorrowedFd<'_> {
7172
impl OwnedFd {
7273
/// Creates a new `OwnedFd` instance that shares the same underlying file handle
7374
/// as the existing `OwnedFd` instance.
75+
#[cfg(not(target_os = "wasi"))]
7476
pub fn try_clone(&self) -> crate::io::Result<Self> {
7577
// We want to atomically duplicate this file descriptor and set the
7678
// CLOEXEC flag, and currently that's done via F_DUPFD_CLOEXEC. This
@@ -88,6 +90,14 @@ impl OwnedFd {
8890
let fd = cvt(unsafe { libc::fcntl(self.as_raw_fd(), cmd, 0) })?;
8991
Ok(unsafe { Self::from_raw_fd(fd) })
9092
}
93+
94+
#[cfg(target_os = "wasi")]
95+
pub fn try_clone(&self) -> crate::io::Result<Self> {
96+
Err(crate::io::Error::new_const(
97+
crate::io::ErrorKind::Unsupported,
98+
&"operation not supported on WASI yet",
99+
))
100+
}
91101
}
92102

93103
#[unstable(feature = "io_safety", issue = "87074")]

0 commit comments

Comments
 (0)