diff --git a/tokio/src/io/stderr.rs b/tokio/src/io/stderr.rs index fa5d0fbd11e..99607dc6044 100644 --- a/tokio/src/io/stderr.rs +++ b/tokio/src/io/stderr.rs @@ -72,6 +72,20 @@ cfg_io_std! { } } +#[cfg(unix)] +impl std::os::unix::io::AsRawFd for Stderr { + fn as_raw_fd(&self) -> std::os::unix::io::RawFd { + std::io::stderr().as_raw_fd() + } +} + +#[cfg(windows)] +impl std::os::windows::io::AsRawHandle for Stderr { + fn as_raw_handle(&self) -> std::os::windows::io::RawHandle { + std::io::stderr().as_raw_handle() + } +} + impl AsyncWrite for Stderr { fn poll_write( mut self: Pin<&mut Self>, diff --git a/tokio/src/io/stdin.rs b/tokio/src/io/stdin.rs index 6c93744794b..634bd484967 100644 --- a/tokio/src/io/stdin.rs +++ b/tokio/src/io/stdin.rs @@ -45,6 +45,20 @@ cfg_io_std! { } } +#[cfg(unix)] +impl std::os::unix::io::AsRawFd for Stdin { + fn as_raw_fd(&self) -> std::os::unix::io::RawFd { + std::io::stdin().as_raw_fd() + } +} + +#[cfg(windows)] +impl std::os::windows::io::AsRawHandle for Stdin { + fn as_raw_handle(&self) -> std::os::windows::io::RawHandle { + std::io::stdin().as_raw_handle() + } +} + impl AsyncRead for Stdin { fn poll_read( mut self: Pin<&mut Self>, diff --git a/tokio/src/io/stdout.rs b/tokio/src/io/stdout.rs index ff1bfd5d453..5377993a466 100644 --- a/tokio/src/io/stdout.rs +++ b/tokio/src/io/stdout.rs @@ -72,6 +72,20 @@ cfg_io_std! { } } +#[cfg(unix)] +impl std::os::unix::io::AsRawFd for Stdout { + fn as_raw_fd(&self) -> std::os::unix::io::RawFd { + std::io::stdout().as_raw_fd() + } +} + +#[cfg(windows)] +impl std::os::windows::io::AsRawHandle for Stdout { + fn as_raw_handle(&self) -> std::os::windows::io::RawHandle { + std::io::stdout().as_raw_handle() + } +} + impl AsyncWrite for Stdout { fn poll_write( mut self: Pin<&mut Self>,