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

std::process should provide a facility to specify custom file descriptors to stdin/stdout/stderr #893

Closed
achernya opened this issue Feb 22, 2015 · 3 comments

Comments

@achernya
Copy link

Currently, RFC #517 specifies that "The equivalent of today's InheritFd will be added at a later point.". However, this severely limits the utility of std::process. My current use case is writing a (toy) shell, without resorting to libc::*. Unfortunately, without support for setting custom file descriptors in std::process, it's not possible to implement features like file redirection or pipelines.

From my reading of libstd/process.rs and libstd/sys/${PLATFORM}/process2.rs, it looks like all of the platform-specific code for handling AnonPipe/FileDesc is already in place, and a small change to the API of process.rs would allow for setting custom AnonPipe.

I'm happy to work on a patch (assuming that I haven't missed any important details in my analysis regarding difficulty).

@l0kod
Copy link

l0kod commented Feb 24, 2015

cc #899

l0kod referenced this issue in alexcrichton/rust Mar 1, 2015
This is an implementation of RFC 899 and adds stdio functionality to the new
`std::io` module. Details of the API can be found on the RFC, but from a high
level:

* `io::{stdin, stdout, stderr}` constructors are now available. There are also
  `*_raw` variants for unbuffered and unlocked access.
* All handles are globally shared (excluding raw variants).
* The stderr handle is no longer buffered.
* All handles can be explicitly locked (excluding the raw variants).

The `print!` and `println!` machinery has not yet been hooked up to these
streams just yet. The `std::fmt::output` module has also not yet been
implemented as part of this commit.
@arthurprs
Copy link

sub, I guess this should be also posted in rust repo

@alexcrichton
Copy link
Member

I'm going to close this in favor of #941 now that I've opened it, but thanks for the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants