Skip to content

Tracking Issue for StdioExt #150667

@the8472

Description

@the8472

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

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-unimplementedStatus: The feature has not been implemented.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions