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 16, 2025
1 parent 67c343d commit 98c544a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tokio/src/process/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,11 @@ 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`.
///
/// Note: behavior of this function is different from std version of
/// [`Child::kill`](std::process::Child::kill): std version does `wait`.
/// Tokio equivalent of std `Child::kill` is [`start_kill`](Child::start_kill).
///
/// # Examples
///
Expand Down

0 comments on commit 98c544a

Please sign in to comment.