Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Router] fix interrupt from terminal #2413

Merged
merged 1 commit into from
Dec 9, 2024
Merged

Conversation

ByronHsu
Copy link
Collaborator

@ByronHsu ByronHsu commented Dec 9, 2024

The key interrupt from the terminal is not handled properly, causing uncleaned subprocesses. This issue has two main scenarios:

  1. Without os.setpgrp():
    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.
Terminal (PGID=100)
└── Main Python Process (PGID=100)
    └── Server Process 1 (PGID=100)
        └── Scheduler 1
        └── Detokenizer 1
    └── Server Process 2 (PGID=100)
        └── Scheduler 2
        └── Detokenizer 2
  1. With os.setpgrp():
    The main Python process and its children are placed in separate groups. The process hierarchy becomes:
Terminal (PGID=100)
└── Main Python Process (PGID=200)
    └── Server Process 1 (PGID=300)
        └── Scheduler 1
        └── Detokenizer 1
    └── Server Process 2 (PGID=400)
        └── Scheduler 2
        └── Detokenizer 2

By setting new process group IDs, this issue can be resolved.

@ByronHsu ByronHsu requested a review from Ying1123 as a code owner December 9, 2024 00:49
@ByronHsu ByronHsu merged commit 2a717c5 into main Dec 9, 2024
6 checks passed
@ByronHsu ByronHsu deleted the byhsu/fix-int-from-terminal branch December 9, 2024 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant