Skip to content

Commit cefdd6d

Browse files
authored
Rollup merge of rust-lang#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.
2 parents a1286f6 + bc4bd56 commit cefdd6d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/libstd/process.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -1121,8 +1121,13 @@ impl ExitCode {
11211121
}
11221122

11231123
impl Child {
1124-
/// Forces the child to exit. This is equivalent to sending a
1125-
/// SIGKILL on unix platforms.
1124+
/// Forces the child process to exit. If the child has already exited, an [`InvalidInput`]
1125+
/// error is returned.
1126+
///
1127+
/// The mapping to [`ErrorKind`]s is not part of the compatibility contract of the function,
1128+
/// especially the [`Other`] kind might change to more specific kinds in the future.
1129+
///
1130+
/// This is equivalent to sending a SIGKILL on Unix platforms.
11261131
///
11271132
/// # Examples
11281133
///
@@ -1138,6 +1143,10 @@ impl Child {
11381143
/// println!("yes command didn't start");
11391144
/// }
11401145
/// ```
1146+
///
1147+
/// [`ErrorKind`]: ../io/enum.ErrorKind.html
1148+
/// [`InvalidInput`]: ../io/enum.ErrorKind.html#variant.InvalidInput
1149+
/// [`Other`]: ../io/enum.ErrorKind.html#variant.Other
11411150
#[stable(feature = "process", since = "1.0.0")]
11421151
pub fn kill(&mut self) -> io::Result<()> {
11431152
self.handle.kill()

0 commit comments

Comments
 (0)