Rollup merge of #49461 - andreastt:child-kill-exited, r=Mark-Simulacrum

std: Child::kill() returns error if process has already exited

This patch makes it clear in std::process::Child::kill()'s API
documentation that an error is returned if the child process has
already cleanly exited.  This is implied by the example, but not
called out explicitly.
This commit is contained in:
kennytm 2018-04-24 11:56:59 +08:00 committed by GitHub
commit cefdd6d5e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1121,8 +1121,13 @@ impl ExitCode {
} }
impl Child { impl Child {
/// Forces the child to exit. This is equivalent to sending a /// Forces the child process to exit. If the child has already exited, an [`InvalidInput`]
/// SIGKILL on unix platforms. /// error is returned.
///
/// The mapping to [`ErrorKind`]s is not part of the compatibility contract of the function,
/// especially the [`Other`] kind might change to more specific kinds in the future.
///
/// This is equivalent to sending a SIGKILL on Unix platforms.
/// ///
/// # Examples /// # Examples
/// ///
@ -1138,6 +1143,10 @@ impl Child {
/// println!("yes command didn't start"); /// println!("yes command didn't start");
/// } /// }
/// ``` /// ```
///
/// [`ErrorKind`]: ../io/enum.ErrorKind.html
/// [`InvalidInput`]: ../io/enum.ErrorKind.html#variant.InvalidInput
/// [`Other`]: ../io/enum.ErrorKind.html#variant.Other
#[stable(feature = "process", since = "1.0.0")] #[stable(feature = "process", since = "1.0.0")]
pub fn kill(&mut self) -> io::Result<()> { pub fn kill(&mut self) -> io::Result<()> {
self.handle.kill() self.handle.kill()