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

Wait for all processes in the process group #7

Merged
merged 2 commits into from Dec 3, 2022

Conversation

malyn
Copy link
Contributor

@malyn malyn commented Nov 19, 2022

This avoids zombie processes that would otherwise be created if the child process exits after spawning its own children, but without waiting for those children to exit. This change ensures that wait reaps all of those zombie processes, while still returning the exit code from the original process that was spawned (Command Group's direct child).

One note: I wasn't entirely sure if this should be in Command Group or in my application code, but the documentation of the AsyncGroupChild::wait function suggested that cleaning up all of the children in the process group might have been what was intended:

Waits for the child group to exit completely, returning the status that the process leader exited with.

The Tokio code does not perform this reaping though, and I realize that Command Group is ultimately based on the Tokio API, so, as I said, not entirely sure if this is the right place for this logic.

@passcod
Copy link
Member

passcod commented Nov 19, 2022

Thank you!

@passcod
Copy link
Member

passcod commented Nov 19, 2022

bors r+

bors bot added a commit that referenced this pull request Nov 19, 2022
7: Wait for all processes in the process group r=passcod a=malyn

This avoids zombie processes that would otherwise be created if the child process exits after spawning its own children, but without waiting for those children to exit. This change ensures that `wait` reaps all of those zombie processes, while still returning the exit code from the original process that was spawned (Command Group's direct child).

One note: I wasn't entirely sure if this should be in Command Group or in my application code, but the documentation of the [`AsyncGroupChild::wait`](https://docs.rs/command-group/1.0.8/command_group/struct.AsyncGroupChild.html#method.wait) function suggested that cleaning up all of the children in the process *group* might have been what was intended:

> Waits for the child group to exit completely, returning the status that the process leader exited with.

The Tokio code does not perform this reaping though, and I realize that Command Group is ultimately based on the Tokio API, so, as I said, not entirely sure if this is the right place for this logic.

Co-authored-by: Michael Alyn Miller <malyn@strangeGizmo.com>
@bors
Copy link
Contributor

bors bot commented Nov 19, 2022

This avoids zombie processes that would otherwise be created if the child
process exits after spawning its own children, but without waiting for
those children to exit. This change ensures that `wait` reaps all of
those zombie processes, while still returning the exit code from the
original process that was spawned (Command Group's direct child).
@passcod passcod enabled auto-merge (squash) December 3, 2022 14:14
@passcod passcod merged commit 61336e4 into watchexec:main Dec 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants