{{ message }}
Repository navigation
fix(apodex): reap detached shell descendants after timeout - #64
Open
zhanghanduo wants to merge 4 commits into
Open
zhanghanduo wants to merge 4 commits into
zhanghanduo wants to merge 4 commits into
Conversation
Build on the process-group cleanup proposed in PR #44. On Linux, run each local shell under a child subreaper so descendants that call setsid are adopted, killed, and reaped when the command times out or is cancelled. Co-authored-by: Rishit Sharma <rishitsharmar89@gmail.com>
Report the supervised shell status over the control socket so an exit caused by a signal keeps its negative return code. Keep timeout and cancellation cleanup separate from normal completion.
`python -m apodex._shell_supervisor` with cwd set to the workspace put the workspace first on sys.path, so a workspace apodex/ package (or ctypes.py / select.py) could replace the supervisor or the stdlib modules it imports, and the module failed to resolve when apodex was importable only from the source root. Run the supervisor by absolute path under -P instead. Generated with [Claude Code](https://claude.ai/code) via [Very Happy](https://github.com/Mereithhh/very-happy) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
When the Linux supervisor cannot become a subreaper or read /proc/self/task/<pid>/children, it exits before running the command. The caller then returned the supervisor's own exit code, so the bash tool showed an ordinary "[exit code 1]" with a traceback for a command that never ran. Raise a RuntimeError saying the command was not run, with the cause. Generated with [Claude Code](https://claude.ai/code) via [Very Happy](https://github.com/Mereithhh/very-happy) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Collaborator
Author
This branch has not been deployed
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.

Problem
Issue #40 remains open on
main.apodex.sandbox.run_shellcancelsproc.communicate()on timeout but leaves the command running. PR #44 adds a process-group kill and fixes the exited-shell/background-child case; this PR builds on that work and addresses the remaining case: a child can callsetsid()(orPopen(start_new_session=True)) and escape the shell's process group. In a reproduction,run_shellreturnedTimeoutErrorand that child wrote to the workspace afterward.Fix
TimeoutError/ cancellation behavior.This supersedes PR #44's implementation. Credit to @Rish-it for the original process-group fix and tests; their contribution is recorded in the commit trailer.
Verification
test_native.py— 23 passed, 4 Linux-only tests skipped; new process-group tests run withResourceWarningtreated as an error.setsidregression cases (running/exited shell × timeout/cancellation) and the signal exit-status regression. Ruff, Pyright, import smoke, release gates, and CodeQL also passed.Fixes #40.