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
Allow blocking Command::output
#105458
Allow blocking Command::output
#105458
Conversation
Add `read_to_end` method for `sys::{target}::pipe::AnonPipe`. This allows
having a more optimized version of `read_to_end` for ChildStdout.
Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
|
(rustbot has picked a reviewer for you, use r? to override) |
|
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
|
It seems like this doesn't change or add support itself for any platforms that can block but not spawn a subprocess, right? That will come in a future PR? I think the changes here seem fine -- but the PR description could be updated to make clear that this isn't changing anything, just shuffling some APIs to make it easier to make changes in the future. |
Ok, will do that. I specifically made this change for UEFI (#100316) but it should be helpful for any target that is similar. |
Command::output
|
@rustbot ready |
|
Thanks! @bors r+ |
…imulacrum Allow blocking `Command::output` ### Problem Currently, `Command::output` is internally implemented using `Command::spawn`. This is problematic because some targets (like UEFI) do not actually support multitasking and thus block while the program is executing. This coupling does not make much sense as `Command::output` is supposed to block until the execution is complete anyway and thus does not need to rely on a non-blocking `Child` or any other intermediate. ### Solution This PR moves the implementation of `Command::output` to `std::sys`. This means targets can choose to implement only `Command::output` without having to implement `Command::spawn`. ### Additional Information This was originally conceived when working on rust-lang#100316. Currently, the only target I know about that will benefit from this change is UEFI. This PR can also be used to implement more efficient `Command::output` since the intermediate `Process` is not actually needed anymore, but that is outside the scope of this PR. Since this is not a public API change, I'm not sure if an RFC is needed or not.
|
@bors r- failed in a rollup |
This allows decoupling `Command::spawn` and `Command::output`. This is useful for targets which do support launching programs in blocking mode but do not support multitasking (Eg: UEFI). This was originally conceived when working on rust-lang#100316 Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
1ba9790
to
a94793d
Compare
|
@rustbot ready |
|
@bors r+ rollup |
…imulacrum Allow blocking `Command::output` ### Problem Currently, `Command::output` is internally implemented using `Command::spawn`. This is problematic because some targets (like UEFI) do not actually support multitasking and thus block while the program is executing. This coupling does not make much sense as `Command::output` is supposed to block until the execution is complete anyway and thus does not need to rely on a non-blocking `Child` or any other intermediate. ### Solution This PR moves the implementation of `Command::output` to `std::sys`. This means targets can choose to implement only `Command::output` without having to implement `Command::spawn`. ### Additional Information This was originally conceived when working on rust-lang#100316. Currently, the only target I know about that will benefit from this change is UEFI. This PR can also be used to implement more efficient `Command::output` since the intermediate `Process` is not actually needed anymore, but that is outside the scope of this PR. Since this is not a public API change, I'm not sure if an RFC is needed or not.
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#104854 (Symlink `build/host` -> `build/$HOST_TRIPLE`) - rust-lang#105458 (Allow blocking `Command::output`) - rust-lang#105559 (bootstrap: Allow installing `llvm-tools`) - rust-lang#105789 (rustdoc: clean up margin CSS for scraped examples) - rust-lang#105792 (docs: add long error explanation for error E0320) - rust-lang#105814 (Support call and drop terminators in custom mir) - rust-lang#105829 (Speed up tidy) - rust-lang#105836 (std::fmt: Use args directly in example code) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Problem
Currently,
Command::outputis internally implemented usingCommand::spawn. This is problematic because some targets (like UEFI) do not actually support multitasking and thus block while the program is executing. This coupling does not make much sense asCommand::outputis supposed to block until the execution is complete anyway and thus does not need to rely on a non-blockingChildor any other intermediate.Solution
This PR moves the implementation of
Command::outputtostd::sys. This means targets can choose to implement onlyCommand::outputwithout having to implementCommand::spawn.Additional Information
This was originally conceived when working on #100316. Currently, the only target I know about that will benefit from this change is UEFI.
This PR can also be used to implement more efficient
Command::outputsince the intermediateProcessis not actually needed anymore, but that is outside the scope of this PR.Since this is not a public API change, I'm not sure if an RFC is needed or not.