Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command cannot replumb stdout to stderr #79731

Closed
ijackson opened this issue Dec 5, 2020 · 1 comment
Closed

Command cannot replumb stdout to stderr #79731

ijackson opened this issue Dec 5, 2020 · 1 comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@ijackson
Copy link
Contributor

ijackson commented Dec 5, 2020

When running a Command, it is often desirable to plumb stdout to the same place as stderr, as if 2>&1 in a shell rune.

Unfortunately, there is no way to do this with Command right now without writing unsafe, non-portable code.

Really we want to fix this so that you can pass to Command anything that implements AsRawFd, so probably the right thing would be std::Process::Stdio::reuse<F:AsRawFd>(fd: &f). The implementation is not entirely trivial - we need an fd-permuting algorithm that avoids making unnecessary calls to dup2.

On Windows that would be std::Process::Stdio::reuse<F:AsRawHandle>(fd: &f) I guess.

It's a shame that we have totally separate names for *RawFd and *RawHandle rather than a portable-opaque but nonportably-transparent OsOpenFileReference type and AsOsOpenFileReference, IntoOsOpenFileReference, FromOsOpenFileReference but that seems like rather a major change.

@jonas-schievink jonas-schievink added C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Dec 5, 2020
@fmease
Copy link
Member

fmease commented Dec 28, 2024

This was addressed in #114590. Closing as fixed.

@fmease fmease closed this as completed Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants