Repository navigation
[codex] fix runtime cancellation state sync #1638
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🌐 Web query:
libc setpgid pre_exec child process group kill negative pid ESRCH tokio💡 Result:
The ESRCH error in the context of sending signals to process groups or setting process group IDs generally stems from a mismatch between the expected PID/PGID and the actual state of the process table [1][2][3]. Killing a Process Group with a Negative PID: When using the kill system call with a negative PID (e.g., kill(-pgid, sig)), the kernel attempts to send the signal to all processes in the process group whose ID equals the absolute value of that PID [4]. An ESRCH error occurs if no process group exists with that ID [4][3]. A common mistake is assuming that a PID is always a valid PGID; however, only the process group leader has a PGID equal to its PID [5][3]. If you wish to signal an entire group, you must ensure you are passing the correct PGID, which can be retrieved via getpgid(pid) [3]. setpgid in pre_exec: When using pre_exec (often in Rust's tokio or std::process) to set the process group of a child process, the setpgid call must occur after fork but before the child executes a new program via execve [6][7]. The setpgid call itself may return ESRCH if the specified process is not the calling process or its child, or if the process has already executed an exec function (which typically triggers EACCES, though behavior with zombies or race conditions can sometimes lead to ESRCH) [1][2][8]. Tokio and Process Groups: To manage process groups in Tokio, the recommended approach is to use the.process_group(pgid) method on tokio::process::Command [9]. This method is stable and allows you to set the PGID for the child process without manually managing pre_exec or unsafe blocks, avoiding potential errors associated with incorrect timing or invalid PID/PGID assumptions [6][9][10]. If you must use pre_exec for custom logic, ensure that you only call setpgid on the child process itself (using getpid inside the child) or its direct children, and handle potential errors gracefully [6].
Citations:
🏁 Script executed:
Repository: wecode-ai/Wegent
Length of output: 18312
Add a short grace window before escalating to
SIGKILL.SIGTERMandSIGKILLare sent back-to-back here, so the child never gets a chance to shut down cleanly. Wait briefly or poll for exit before killing the group.🤖 Prompt for AI Agents