fix(windows): confirm job and descendant completion before returning - #55
Closed
glendigity wants to merge 6 commits into
Closed
fix(windows): confirm job and descendant completion before returning#55glendigity wants to merge 6 commits into
glendigity wants to merge 6 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Windows JobObject waits can report completion while a descendant is still running after the leader exits. The existing completion-port helper accepts any notification,
try_waitreports only the leader status, and both frontends cache that status before confirming job completion.This repair tracks process-creation notifications, retains process handles until they signal exit, and reconciles the observed process count against job accounting. Both
waitandtry_waitcache completion only after the whole observed job has finished. Lost or inconsistent notification evidence returns an I/O error instead of reporting successful cleanup.The retained handles matter: an earlier accounting-only implementation fixed normal waits but still returned early after
TerminateJobObject. Both std and Tokio cancellation regression tests detected that distinction on native Windows.Tokio uses finite background waits with independently owned job/port handles and shared observation state. Cancelling a wait future cannot leave an indefinite worker borrowing handles that the child wrapper subsequently closes.
into_innerpreserves its existing detached-job behavior while releasing the added observation resources.No public API or dependency version changes are required. The existing
job-objectfeature additionally enables the Windows SystemServices bindings for notification constants.The synthetic fixture launches this test executable as a leader and descendant, with all standard streams disconnected. A handshake holds the descendant alive after the leader exits; independently retained process handles verify liveness and cleanup. Coverage includes nonblocking waits, normal completion, explicit termination, repeated waits, a cancelled Tokio wait, inconsistent observation counts and invalid handles.
Verification at
699d18b6c6e6a926f27c807a87b9fb1fa3bc8dc4:1d1cc53c5c3f9c2e8bf4ae0459d780a616dc1015; the leader-exittry_waitregression failed with the expected live-descendant assertion.try_waitandwaitremain incomplete while the descendant is alive, and termination pluswaitcompletes with the descendant signalled exited.nix::errno::Errnoimport insrc/std/core.rs:378; that unrelated import is unchanged.The finite wait interval is not a hard operating-system termination deadline. Spawn/setup-failure cleanup is outside this change.
References: