rust-lang / rust-lang/rust

Tracking Issue for StdioExt

Open
#150,667 0 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-tracking-issue S-tracking-unimplemented T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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.)

  • ACP: rust-lang/libs-team#500
  • #150668
  • #159312
  • Final comment period (FCP)^1
  • Stabilization PR
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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the StdioExt public API and the completed ACP, #150668, and #159312 steps. Read the linked Zulip discussion about Windows handle ownership; the tracking work is done when the unresolved handle behavior is resolved, followed by the final comment period and stabilization PR.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.