diff options
author | Ayush Singh <ayushsingh1325@gmail.com> | 2022-12-08 18:22:33 +0530 |
---|---|---|
committer | Ayush Singh <ayushsingh1325@gmail.com> | 2022-12-11 10:21:40 +0530 |
commit | a94793d8d17e4cfe2e727c30c36e174b8d6b6ee3 (patch) | |
tree | 4a6bb73b64331a1ab40165c5c8892bedb1ec837e /library/std/src/sys/unix/process/process_unix.rs | |
parent | 5479fe5f70bb32f037ff97de03ed185bdf2f54b7 (diff) | |
download | rust-a94793d8d17e4cfe2e727c30c36e174b8d6b6ee3.tar.gz |
Implement blocking output
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 https://github.com/rust-lang/rust/pull/100316
Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
Diffstat (limited to 'library/std/src/sys/unix/process/process_unix.rs')
-rw-r--r-- | library/std/src/sys/unix/process/process_unix.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/library/std/src/sys/unix/process/process_unix.rs b/library/std/src/sys/unix/process/process_unix.rs index 56a805cef73..45616850a37 100644 --- a/library/std/src/sys/unix/process/process_unix.rs +++ b/library/std/src/sys/unix/process/process_unix.rs @@ -132,6 +132,11 @@ impl Command { } } + pub fn output(&mut self) -> io::Result<(ExitStatus, Vec<u8>, Vec<u8>)> { + let (proc, pipes) = self.spawn(Stdio::MakePipe, false)?; + crate::sys_common::process::wait_with_output(proc, pipes) + } + // Attempts to fork the process. If successful, returns Ok((0, -1)) // in the child, and Ok((child_pid, -1)) in the parent. #[cfg(not(target_os = "linux"))] |