Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

process: make Child::kill async #2823

Merged
merged 2 commits into from Sep 8, 2020
Merged

process: make Child::kill async #2823

merged 2 commits into from Sep 8, 2020

Conversation

ipetkov
Copy link
Member

@ipetkov ipetkov commented Sep 7, 2020

Motivation

  • Calling child.kill() but forgetting to call child.wait().await or child.try_wait() afterwards can lead to zombie processes on Unix platforms

Solution

  • This changes the Child::kill to be an async method which awaits the
    child after sending a kill signal.
  • A start_kill method was also added on Child which only sends the
    kill signal to the child process. This allows for kill signals to be
    sent even outside of async contexts.

cc @Darksonn if you have any thoughts around this beyond what we already discussed!

* This changes the `Child::kill` to be an async method which awaits the
  child after sending a kill signal. This avoids leaving zombie
  processes on Unix platforms if the caller forgets to await the child
  after the kill completes
* A `start_kill` method was also added on `Child` which only sends the
  kill signal to the child process. This allows for kill signals to be
  sent even outside of async contexts.
@ipetkov ipetkov added C-enhancement Category: A PR with an enhancement or bugfix. A-tokio Area: The main tokio crate M-process Module: tokio/process labels Sep 7, 2020
Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

tokio/src/process/mod.rs Outdated Show resolved Hide resolved
Co-authored-by: Alice Ryhl <alice@ryhl.io>
@ipetkov ipetkov merged commit 7c254ec into tokio-rs:master Sep 8, 2020
@ipetkov ipetkov deleted the process-kill branch September 8, 2020 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-enhancement Category: A PR with an enhancement or bugfix. M-process Module: tokio/process
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants