[Router] fix interrupt from terminal #2413
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.
The key interrupt from the terminal is not handled properly, causing uncleaned subprocesses. This issue has two main scenarios:
All processes share the same Process Group ID (PGID). When you press Ctrl+C, the terminal sends SIGINT to all processes in the group simultaneously. This can cause leaf processes to terminate first, disrupting the proper cleanup order and producing orphaned processes.
The main Python process and its children are placed in separate groups. The process hierarchy becomes:
By setting new process group IDs, this issue can be resolved.