@@ -40,11 +40,15 @@ use thread;
40
40
/// ```should_panic
41
41
/// use std::process::Command;
42
42
///
43
- /// let output = Command::new("/bin/cat").arg("file.txt").output().unwrap_or_else(|e| {
44
- /// panic!("failed to execute child: {}", e)
45
- /// });
46
- /// let contents = output.stdout;
47
- /// assert!(output.status.success());
43
+ /// let mut child = Command::new("/bin/cat")
44
+ /// .arg("file.txt")
45
+ /// .spawn()
46
+ /// .unwrap_or_else(|e| { panic!("failed to execute child: {}", e) });
47
+ ///
48
+ /// let ecode = child.wait()
49
+ /// .unwrap_or_else(|e| { panic!("failed to wait on child: {}", e) });
50
+ ///
51
+ /// assert!(ecode.success());
48
52
/// ```
49
53
#[ stable( feature = "process" , since = "1.0.0" ) ]
50
54
pub struct Child {
@@ -118,9 +122,11 @@ impl Read for ChildStderr {
118
122
/// ```
119
123
/// use std::process::Command;
120
124
///
121
- /// let output = Command::new("sh").arg("-c").arg("echo hello").output().unwrap_or_else(|e| {
122
- /// panic!("failed to execute process: {}", e)
123
- /// });
125
+ /// let output = Command::new("sh")
126
+ /// .arg("-c")
127
+ /// .arg("echo hello")
128
+ /// .output()
129
+ /// .unwrap_or_else(|e| { panic!("failed to execute process: {}", e) });
124
130
/// let hello = output.stdout;
125
131
/// ```
126
132
#[ stable( feature = "process" , since = "1.0.0" ) ]
@@ -140,7 +146,7 @@ impl Command {
140
146
/// * No arguments to the program
141
147
/// * Inherit the current process's environment
142
148
/// * Inherit the current process's working directory
143
- /// * Inherit stdin/stdout/stderr for `run ` or `status`, but create pipes for `output`
149
+ /// * Inherit stdin/stdout/stderr for `spawn ` or `status`, but create pipes for `output`
144
150
///
145
151
/// Builder methods are provided to change these defaults and
146
152
/// otherwise configure the process.
@@ -202,23 +208,20 @@ impl Command {
202
208
}
203
209
204
210
/// Configuration for the child process's stdin handle (file descriptor 0).
205
- /// Defaults to `CreatePipe(true, false)` so the input can be written to.
206
211
#[ stable( feature = "process" , since = "1.0.0" ) ]
207
212
pub fn stdin ( & mut self , cfg : Stdio ) -> & mut Command {
208
213
self . stdin = Some ( cfg. 0 ) ;
209
214
self
210
215
}
211
216
212
217
/// Configuration for the child process's stdout handle (file descriptor 1).
213
- /// Defaults to `CreatePipe(false, true)` so the output can be collected.
214
218
#[ stable( feature = "process" , since = "1.0.0" ) ]
215
219
pub fn stdout ( & mut self , cfg : Stdio ) -> & mut Command {
216
220
self . stdout = Some ( cfg. 0 ) ;
217
221
self
218
222
}
219
223
220
224
/// Configuration for the child process's stderr handle (file descriptor 2).
221
- /// Defaults to `CreatePipe(false, true)` so the output can be collected.
222
225
#[ stable( feature = "process" , since = "1.0.0" ) ]
223
226
pub fn stderr ( & mut self , cfg : Stdio ) -> & mut Command {
224
227
self . stderr = Some ( cfg. 0 ) ;
@@ -356,7 +359,7 @@ pub struct Output {
356
359
pub stderr : Vec < u8 > ,
357
360
}
358
361
359
- /// Describes what to do with a standard io stream for a child process.
362
+ /// Describes what to do with a standard I/O stream for a child process.
360
363
#[ stable( feature = "process" , since = "1.0.0" ) ]
361
364
pub struct Stdio ( StdioImp ) ;
362
365
0 commit comments