-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add new API for named fifo #416
Comments
// Use TryFrom here, because not every owned fd is a valid pipe
#[cfg(unix)]
impl TryFrom<OwnedFd> for Fifo { ... }
#[cfg(windows)]
impl TryFrom<OwnedHandle> for Fifo { ... } We allow implementing If you turn a non-pipe fd to a |
Thanks, I've updated the proposed API |
We discussed this in the libs-api meeting. A question was raised of whether this is sufficiently different from a |
@Amanieu There are quite some differences:
It'd be better to create a dedicated abstraction for fifo. |
Surprising but easily documented: people can open it with a
Neither do various other things that you can turn into a
If we expose those at all, we could expose them as methods taking
So do some other kinds of file descriptor. |
We discussed this in today's @rust-lang/libs-api meeting. We don't want to accept this ACP as written, and in particular don't want a separate Fifo type. We would, however, accept a PR adding |
Proposal
Problem statement
Annoymous and named pipe are widely used, there is crate os_pipe which just provides an abstraction for pipe on unix and has 15 million download.
While having a third-party crate for it is enough for many crates, I think it'd be better if it's in stdlib so that it can be used without having to another dependency for this.
It would also enable better integration with the
std::process
API, since users might want to pipe output of multiple processes to one pipe and read them.Motivating examples or use cases
jobserver-rs, for example, is used by cc-rs and pulled in as build-dependencies quite often.
It internally implements all kinds of API for named fifo, contains a bunch of unsafe code for this and quite some code for just managing the fifo.
It'd be great if we could move them to stdlib and make jobserver-rs easier to maintain.
It might also speedup jobserver-rs compilation since it could've drop the libc dependency.
tokio, the widely used async executor, already provide pipe support in mod tokio::net::unix::pipe.
Solution sketch
Alternatives
Alternatively, we could let the user to use
File
to open a fifo, howeverFile
has different characteristics from a fifo and the user would still need a third-party to create a fifo.Or we could just leave them up to third-party crates, which is the current status-quo, which is OK-ish but not good enough
for users who needfifo, they would have to grab a third-party crate for this.
Links and related work
The text was updated successfully, but these errors were encountered: