-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
process: allow for ergonomically piping stdio of one child into another #3466
Conversation
* Add `TryInto<Stdio>` impls for `ChildStd{in,out,err}` for ergonomic conversions into `std::process::Stdio` so callers can perform the conversion without needing to manipulate raw fds/handles directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good to me.
Co-authored-by: Alice Ryhl <[email protected]>
This comment has been minimized.
This comment has been minimized.
Turns out the tests were catching a subtle bug, namely, not resetting the Requesting a re-review for the new logic that was added! |
// Ensure that the fd to be inherited is set to *blocking* mode, as this | ||
// is the default that virtually all programs expect to have. Those | ||
// programs that know how to work with nonblocking stdio will know how to | ||
// change it to nonblocking mode. | ||
set_nonblocking(&mut fd, false)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is ok because neither end of the pipe is actually used in Tokio?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. One end of the pipe should be owned by the child process (and already closed in the parent). The other end of the pipe is moved into this function, and calling .into_inner()
unwraps the PollEvented
and deregisters it from the reactor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the test passes, then this is good to me.
TryInto<Stdio>
impls forChildStd{in,out,err}
for ergonomicconversions into
std::process::Stdio
so callers can perform theconversion without needing to manipulate raw fds/handles directly
Fixes #3465