Feature gate: #![feature(stdio_swap)]
This is a tracking issue for the std::os::{unix, windows}::io::StdioExt extension traits
that provide ways to redirect stdio to new file handles.
Public API
// unix
pub trait StdioExt {
fn set_fd<T: Into<OwnedFd>>(&mut self, fd: T) -> io::Result<()>;
fn replace_fd<T: Into<OwnedFd>>(&mut self, replace_with: T) -> io::Result<OwnedFd>;
fn take_fd(&mut self) -> io::Result<OwnedFd>;
}
// windows
pub trait StdioExt {
fn set_handle<T: Into<OwnedHandle>>(&mut self, handle: Option<T>) -> io::Result<()>;
fn replace_handle<T: Into<OwnedHandle>>(&mut self, replace_with: T) -> io::Result<Option<BorrowedHandle<'static>>>;
fn take_handle(&mut self) -> io::Result<Option<BorrowedHandle<'static>>>;
}
Steps / History
(Remember to update the S-tracking-* label when checking boxes.)
Unresolved Questions
- The windows API leaks the old handles handles because they're
essentially BorrowedHandle<'static> and might be in use by other threads.
This can lead to pipes not getting closed, which may be unexpected.
#t-libs > take, close and replace for stdio
Feature gate:
#![feature(stdio_swap)]This is a tracking issue for the
std::os::{unix, windows}::io::StdioExtextension traitsthat provide ways to redirect stdio to new file handles.
Public API
Steps / History
(Remember to update the
S-tracking-*label when checking boxes.)set,closeandtakemethods libs-team#500Unresolved Questions
essentially
BorrowedHandle<'static>and might be in use by other threads.This can lead to pipes not getting closed, which may be unexpected.
#t-libs > take, close and replace for stdio
Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩