You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(process): distinguish between signals used to kill children (#10049)
### Description
This is a redo of #10027 with some additional refactoring to reduce the
complexity of this code. These changes should lessens the possibilities
of deadlock or race conditions.
I highly recommend viewing each commit individually.
From original PR:
> This is primarily a code move of the `ProcessManager` out of the
`turborepo-lib` crate. We also now differ between a child shutting down
in response to a `SIGINT` vs us killing the child.
> Future PR will be changing how we treat each of these exit outcomes.
The additional commits in this PR:
- Fixed a race condition between between the 2 `wait`s performed by the
`ChildStateManager` where one was called by the task the sent a shutdown
to the child and the other was the default `wait`. If the latter won,
then it would appear another entity killed the child even when it was
really us.
- Changed the return value of `ShutdownStyle::process` to avoid
returning an impossible state
- Remove unused `ChildState::Exited` field which was never read
- Removed shared state between the child handle and the child state
manager
- Simplified child methods
The removal of the shared state is possible since we already have the
exit channel shared between the handles and the manager. Using both a
channel and state was error prone as it lead to the following
possibilities:
- What does it mean if the manager is still listening for commands, but
the state shows the child as exited
- What does it mean if the manager channel is closed, but the state
shows the child is still running
Instead we only use the command channel being open/closed as an
indication of if the child is running. Once the manager sees the child
exit, it will send the exit status via the channel and exit resulting in
the channel being closed.
### Testing Instructions
Existing test suite, ran with `hyperfine 'cargo test' -r 500` to attempt
to flush out any races.
0 commit comments