process: remove Future impl on Child #2796
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
The
tokio::process::Child
type implementsFuture
directly which makes it awkward to use, especially when coming from the synchronous version from the standard library. For example, it is impossible to check the status of the command from outside of async contexts.Solution
Future
impl onChild
in favor of an async.wait()
method, which mirrors the stdlib API.try_wait()
method similar to the stdlib one. This API will not register for wake ups and is safe to invoke from non-async codeChild::id
method to return anOption<u32>
to better note that once a child has been reaped, it may not be safe to reuse that identifier (e.g. if the caller wants to interact with the raw process directly). This is the only API which differs from the stdlibRefs #2432