about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorMark Simulacrum <mark.simulacrum@gmail.com>2017-05-19 14:16:16 -0600
committerGitHub <noreply@github.com>2017-05-19 14:16:16 -0600
commit862e7d4af89a694301e3c5eca49e3d5ed77fbf3d (patch)
tree3ef72dc0e3a4763a8d8a84dc692e152bf203de18 /src/libstd
parent8b93680d28f7f8aa726225f3737303f8b75be600 (diff)
parentb2fc7b1cbeae1e6cb1a5b4797d221733592ae6a4 (diff)
downloadrust-862e7d4af89a694301e3c5eca49e3d5ed77fbf3d.tar.gz
rust-862e7d4af89a694301e3c5eca49e3d5ed77fbf3d.zip
Rollup merge of #42024 - citizen428:docs/update-exitstatus, r=steveklabnik
Add documentation for `ExitStatus`

As requested in #29370. r? @steveklabnik
Diffstat (limited to 'src/libstd')
-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 3896fc20a2d..d0e7defbbbb 100644
--- a/src/libstd/process.rs
+++ b/src/libstd/process.rs
@@ -754,6 +754,13 @@ impl fmt::Debug for Stdio {
 }
 
 /// Describes the result of a process after it has terminated.
+///
+/// This `struct` is used to represent the exit status of a child process.
+/// Child processes are created via the [`Command`] struct and their exit
+/// status is exposed through the [`status`] method.
+///
+/// [`Command`]: struct.Command.html
+/// [`status`]: struct.Command.html#method.status
 #[derive(PartialEq, Eq, Clone, Copy, Debug)]
 #[stable(feature = "process", since = "1.0.0")]
 pub struct ExitStatus(imp::ExitStatus);
@@ -788,6 +795,22 @@ impl ExitStatus {
     /// On Unix, this will return `None` if the process was terminated
     /// by a signal; `std::os::unix` provides an extension trait for
     /// extracting the signal and other details from the `ExitStatus`.
+    ///
+    /// # Examples
+    ///
+    /// ```no_run
+    /// use std::process::Command;
+    ///
+    /// let status = Command::new("mkdir")
+    ///                      .arg("projects")
+    ///                      .status()
+    ///                      .expect("failed to execute mkdir");
+    ///
+    /// match status.code() {
+    ///     Some(code) => println!("Exited with status code: {}", code),
+    ///     None       => println!("Process terminated by signal")
+    /// }
+    /// ```
     #[stable(feature = "process", since = "1.0.0")]
     pub fn code(&self) -> Option<i32> {
         self.0.code()