diff options
| author | Dan Gohman <dev@sunfishcode.online> | 2021-08-19 12:24:25 -0700 |
|---|---|---|
| committer | Dan Gohman <dev@sunfishcode.online> | 2021-08-19 13:27:19 -0700 |
| commit | e555003e6d6b6d71ce5509a6b6c7a15861208d6c (patch) | |
| tree | be8caa2cd65607d9d2d67df621283668f9fd8a60 /library/std/src/os/unix/process.rs | |
| parent | 0377a633520344c6530f21fffee4d31768c9c447 (diff) | |
| download | rust-e555003e6d6b6d71ce5509a6b6c7a15861208d6c.tar.gz rust-e555003e6d6b6d71ce5509a6b6c7a15861208d6c.zip | |
Factor out a common `RawFd`/`AsRawFd`/etc for Unix and WASI.
Diffstat (limited to 'library/std/src/os/unix/process.rs')
| -rw-r--r-- | library/std/src/os/unix/process.rs | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/library/std/src/os/unix/process.rs b/library/std/src/os/unix/process.rs index f2e8832cc92..650dcbabbae 100644 --- a/library/std/src/os/unix/process.rs +++ b/library/std/src/os/unix/process.rs @@ -4,7 +4,7 @@ use crate::ffi::OsStr; use crate::io; -use crate::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; +use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; use crate::process; use crate::sealed::Sealed; use crate::sys; @@ -385,6 +385,54 @@ impl IntoRawFd for process::ChildStderr { } } +#[unstable(feature = "io_safety", issue = "87074")] +impl AsFd for crate::process::ChildStdin { + #[inline] + fn as_fd(&self) -> BorrowedFd<'_> { + self.as_inner().as_fd() + } +} + +#[unstable(feature = "io_safety", issue = "87074")] +impl From<crate::process::ChildStdin> for OwnedFd { + #[inline] + fn from(child_stdin: crate::process::ChildStdin) -> OwnedFd { + child_stdin.into_inner().into_inner().into_inner() + } +} + +#[unstable(feature = "io_safety", issue = "87074")] +impl AsFd for crate::process::ChildStdout { + #[inline] + fn as_fd(&self) -> BorrowedFd<'_> { + self.as_inner().as_fd() + } +} + +#[unstable(feature = "io_safety", issue = "87074")] +impl From<crate::process::ChildStdout> for OwnedFd { + #[inline] + fn from(child_stdout: crate::process::ChildStdout) -> OwnedFd { + child_stdout.into_inner().into_inner().into_inner() + } +} + +#[unstable(feature = "io_safety", issue = "87074")] +impl AsFd for crate::process::ChildStderr { + #[inline] + fn as_fd(&self) -> BorrowedFd<'_> { + self.as_inner().as_fd() + } +} + +#[unstable(feature = "io_safety", issue = "87074")] +impl From<crate::process::ChildStderr> for OwnedFd { + #[inline] + fn from(child_stderr: crate::process::ChildStderr) -> OwnedFd { + child_stderr.into_inner().into_inner().into_inner() + } +} + /// Returns the OS-assigned process identifier associated with this process's parent. #[stable(feature = "unix_ppid", since = "1.27.0")] pub fn parent_id() -> u32 { |
