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.
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: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.