process: Add support for stdio streams

This commit is contained in:
Andreas Rottmann
2019-06-24 16:56:47 -07:00
committed by Ivan Petkov
parent b16a8613b1
commit 849a5ad0b2
5 changed files with 197 additions and 4 deletions
+30
View File
@@ -1,6 +1,7 @@
#[macro_use]
extern crate futures;
extern crate tokio_core;
extern crate mio;
use std::ffi::OsStr;
use std::io;
@@ -18,6 +19,9 @@ mod imp;
#[cfg(windows)]
mod imp;
pub use imp::ChildStdin;
pub use imp::ChildStdout;
pub struct Command {
inner: process::Command,
#[allow(dead_code)]
@@ -94,6 +98,20 @@ impl Command {
self
}
pub fn stdin(&mut self, cfg: process::Stdio) -> &mut Self {
self.inner.stdin(cfg);
self
}
pub fn stdout(&mut self, cfg: process::Stdio) -> &mut Self {
self.inner.stdout(cfg);
self
}
pub fn stderr(&mut self, cfg: process::Stdio) -> &mut Self {
self.inner.stderr(cfg);
self
}
pub fn spawn(self) -> Spawn {
Spawn {
inner: Box::new(imp::spawn(self).map(|c| Child { inner: c })),
@@ -118,6 +136,18 @@ impl Child {
pub fn kill(&mut self) -> io::Result<()> {
self.inner.kill()
}
pub fn stdin(&mut self) -> &mut Option<imp::ChildStdin> {
&mut self.inner.stdin
}
pub fn stdout(&mut self) -> &mut Option<imp::ChildStdout> {
&mut self.inner.stdout
}
pub fn stderr(&mut self) -> &mut Option<imp::ChildStderr> {
&mut self.inner.stderr
}
}
impl Future for Child {