about summary refs log tree commit diff
path: root/src/libstd/process.rs
diff options
context:
space:
mode:
authorLukas Pustina <lukas.pustina@centerdevice.com>2016-03-18 16:11:37 +0100
committerLukas Pustina <lukas.pustina@centerdevice.com>2016-03-18 16:11:37 +0100
commit8d61cb245d10bb2a61928cfa8651b1e88e7b115a (patch)
tree36e7cfb64ab7e9b78cbce01de0dd70dd7736507c /src/libstd/process.rs
parent2de6ddd75e202acdedfcd05b51a863dcc10459ca (diff)
downloadrust-8d61cb245d10bb2a61928cfa8651b1e88e7b115a.tar.gz
rust-8d61cb245d10bb2a61928cfa8651b1e88e7b115a.zip
Extends rustdoc on how to caputure output
Diffstat (limited to 'src/libstd/process.rs')
-rw-r--r--src/libstd/process.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/libstd/process.rs b/src/libstd/process.rs
index 5813d82a315..b21f745764c 100644
--- a/src/libstd/process.rs
+++ b/src/libstd/process.rs
@@ -499,6 +499,29 @@ impl Child {
     /// before waiting. This helps avoid deadlock: it ensures that the
     /// child does not block waiting for input from the parent, while
     /// the parent waits for the child to exit.
+    ///
+    /// By default, stdin, stdout and stderr are inherited from the parent.
+    /// In order to capture the output into this `Result<Output>` it is
+    /// necessary to create new pipes between parent and child. Use
+    /// `stdout(Stdio::piped())` or `stdout(Stdio::piped())`, respectively.
+    ///
+    /// # Examples
+    ///
+    /// ```should_panic
+    /// use std::process::{Command, Stdio};
+    ///
+    /// let mut child = Command::new("/bin/cat")
+    ///                         .stdout(Stdio::piped())
+    ///                         .arg("file.txt")
+    ///                         .spawn()
+    ///                         .unwrap_or_else(|e| { panic!("failed to execute child: {}", e) });
+    ///
+    /// let ecode = child.wait_with_output()
+    ///                  .unwrap_or_else(|e| { panic!("failed to wait on child: {}", e) });
+    ///
+    /// assert!(ecode.success());
+    /// ```
+    ///
     #[stable(feature = "process", since = "1.0.0")]
     pub fn wait_with_output(mut self) -> io::Result<Output> {
         drop(self.stdin.take());