fix(ipython): terminate %%bash subprocesses on interrupt - #861
Closed
Akashmdshetty wants to merge 2 commits into
Closed
fix(ipython): terminate %%bash subprocesses on interrupt#861Akashmdshetty wants to merge 2 commits into
Akashmdshetty wants to merge 2 commits into
Conversation
zhengr
pushed a commit
to zhengr/prime-agent
that referenced
this pull request
Aug 8, 2026
Contributor
|
Thank you for the report and proposed work. This root cause is now covered by maintainer-owned stacked PR #1162, authored independently from We did not inspect or reuse this PR's diff, branch, commits, implementation code, or tests; its public description/comments were used only as a bug report. To keep one review surface, this PR is superseded by #1162 and is being closed. The complete review stack is #1158–#1165. It is being left unmerged for human review after CI and review-bot findings are cleared. |
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.
Summary
This PR fixes an issue where interrupting a
%%bash/%%scriptcell returns control to the agent but leaves child subprocesses running indefinitely.Changes
%%bash/%%scriptexecute in their own process group.KeyboardInterruptoccurs.Motivation
Previously, interrupting long-running
%%bashcells could leave orphaned subprocesses running after the tool call was abandoned, requiring manual cleanup.Closes #849
Note
Fix
%%bashcell interrupts to terminate subprocess groups in IPythonScriptMagics.shebangin the IPython bootstrap to wrapsubprocess.Popen, creating a new process group for child processes spawned during shebang cell execution.KeyboardInterrupt, sends SIGINT then SIGKILL to the entire child process group (POSIX) or usestaskkill(Windows), ensuring%%bashand similar cells stop reliably.KernelManagerto re-attemptinterrupt()before callingforceAbort()if the same execution is still active.try/exceptto be best-effort and avoid breaking the kernel on failure.Macroscope summarized cbf0eb5.