Skip to content

Commit

Permalink
Clarify Child::kill behavior
Browse files Browse the repository at this point in the history
```
Child::kill       == std Child::kill + Child::wait
Child::start_kill == std Child::kill
```

As a side note, kill that also waits, is convenient, but also
dangerous, because `wait` may hang in certain cases (NFS, ptrace,
etc).  And different behavior between std and tokio may leads to
bugs when code is mechanically converted from one to another.  Better
name name of this function might be `kill_and_wait`.
  • Loading branch information
stepancheg committed Feb 17, 2025
1 parent 383da87 commit 31fd11a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tokio/src/process/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,13 @@ impl Child {

/// Forces the child to exit.
///
/// This is equivalent to sending a `SIGKILL` on unix platforms.
/// This is equivalent to sending a `SIGKILL` on unix platforms
/// followed by [`wait(2)`](https://man7.org/linux/man-pages/man2/wait.2.html)
/// ([`Child::wait`]).
///
/// Note: behavior of this function is different from std version of
/// [`Child::kill`](std::process::Child::kill): std version does not `wait`.
/// Tokio [`start_kill`](Child::start_kill) is equivalent to std `Child::kill`.
///
/// # Examples
///
Expand Down

0 comments on commit 31fd11a

Please sign in to comment.