mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-27 00:00:12 +02:00
process: Add support for stdio streams
This commit is contained in:
+30
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user