Skip to content

Commit 598bee0

Browse files
committed
Command::spawn: example: Actually wait for the Child (!)
Signed-off-by: Ian Jackson <[email protected]>
1 parent 0e19020 commit 598bee0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

library/std/src/process.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -839,9 +839,13 @@ impl Command {
839839
/// ```no_run
840840
/// use std::process::Command;
841841
///
842-
/// Command::new("ls")
842+
/// let status = Command::new("ls")
843843
/// .spawn()
844-
/// .expect("ls command failed to start");
844+
/// .expect("ls command failed to start")
845+
/// .wait()
846+
/// .expect("failed to wait for child");
847+
///
848+
/// assert!(status.success());
845849
/// ```
846850
#[stable(feature = "process", since = "1.0.0")]
847851
pub fn spawn(&mut self) -> io::Result<Child> {

0 commit comments

Comments
 (0)