File tree 1 file changed +23
-0
lines changed
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -499,6 +499,29 @@ impl Child {
499
499
/// before waiting. This helps avoid deadlock: it ensures that the
500
500
/// child does not block waiting for input from the parent, while
501
501
/// the parent waits for the child to exit.
502
+ ///
503
+ /// By default, stdin, stdout and stderr are inherited from the parent.
504
+ /// In order to capture the output into this `Result<Output>` it is
505
+ /// necessary to create new pipes between parent and child. Use
506
+ /// `stdout(Stdio::piped())` or `stdout(Stdio::piped())`, respectively.
507
+ ///
508
+ /// # Examples
509
+ ///
510
+ /// ```should_panic
511
+ /// use std::process::{Command, Stdio};
512
+ ///
513
+ /// let mut child = Command::new("/bin/cat")
514
+ /// .stdout(Stdio::piped())
515
+ /// .arg("file.txt")
516
+ /// .spawn()
517
+ /// .unwrap_or_else(|e| { panic!("failed to execute child: {}", e) });
518
+ ///
519
+ /// let ecode = child.wait_with_output()
520
+ /// .unwrap_or_else(|e| { panic!("failed to wait on child: {}", e) });
521
+ ///
522
+ /// assert!(ecode.success());
523
+ /// ```
524
+ ///
502
525
#[ stable( feature = "process" , since = "1.0.0" ) ]
503
526
pub fn wait_with_output ( mut self ) -> io:: Result < Output > {
504
527
drop ( self . stdin . take ( ) ) ;
You can’t perform that action at this time.
0 commit comments