Repository navigation
fix(bash): let Stop end a command whose output a survivor holds open - #1016
Merged
Merged
Conversation
…647) On Stop, pi's local shell backend kills the command's process tree (process-group SIGKILL on POSIX, `taskkill /T` on Windows) and then waits for every inherited stdout/stderr handle to fall idle, re-arming a 100ms grace timer on each chunk (waitForChildProcess, earendil-works/pi#5303). A descendant the kill cannot reach keeps that wait alive for as long as it writes: a process in its own session on POSIX, or an orphan whose parent already exited on Windows, which `taskkill /T` cannot follow (earendil-works/pi#9129). The bash tool call then never returns, so the Stop request, the Stop button and any queued steering all wait until the script finishes on its own. Pi Web already routes agent and `!` shell commands through its own BashOperations wrapper, so it now bounds that wait there: once the signal aborts, pi's normal path gets one second to settle (it takes well under that when the tree is gone) before the wrapper rejects with pi's own "aborted" error, which the bash tool reports as "Command aborted" and the `!` executor as a cancelled run. Output that arrives after the release is dropped instead of being appended to a result that has already been finalized. The unreachable process itself keeps running; killing it needs an upstream change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Steer button's tooltip promised to "interrupt the current run and inject this message now". Steering does not interrupt anything: pi queues the message and delivers it after the current assistant response and its tool calls finish, before the next model call (pi docs rpc-commands.md, sdk.md). A message steered during a long Python run therefore waits for the script, which the tooltip gave no reason to expect. Describe the real timing and point to Stop, which is what interrupts the running tool calls. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…647) pi's `timeout` kills the process tree and then waits on the inherited output handles exactly like Stop does, so a descendant the kill cannot reach kept the tool call pending past its timeout with no "Command timed out" result. The wrapper now also releases the command one grace period after the timeout, with pi's own `timeout:<seconds>` error. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Kano-u
pushed a commit
to Kano-u/pi-web
that referenced
this pull request
Oct 2, 2026
解开 agegr#981 的 DirectoryPicker 冲突后,这一段(390e70f..f52fd84)实测 0 冲突: - agegr#992 移动端输入框停在键盘上方并给打字更多空间 - agegr#997 限制每客户端 SSE 积压 - agegr#1001 可配置发送键(Enter / Ctrl+Enter) - agegr#1006 从 pi 的 provider catalog 解析 discovery endpoint - agegr#1017 空闲关闭被禁用时回收 Stop 无法解除的运行 - agegr#1016 Stop 结束输出被幸存进程持住的命令 - agegr#1015 保留用户消息里输入的换行 - agegr#1019 在 Safari / iOS 16.2 上可加载(新增 browserslist,无新依赖)
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 6, 2026
…gegr#1016) * fix(bash): let Stop end a command whose output a survivor holds open (agegr#647) On Stop, pi's local shell backend kills the command's process tree (process-group SIGKILL on POSIX, `taskkill /T` on Windows) and then waits for every inherited stdout/stderr handle to fall idle, re-arming a 100ms grace timer on each chunk (waitForChildProcess, earendil-works/pi#5303). A descendant the kill cannot reach keeps that wait alive for as long as it writes: a process in its own session on POSIX, or an orphan whose parent already exited on Windows, which `taskkill /T` cannot follow (earendil-works/pi#9129). The bash tool call then never returns, so the Stop request, the Stop button and any queued steering all wait until the script finishes on its own. Pi Web already routes agent and `!` shell commands through its own BashOperations wrapper, so it now bounds that wait there: once the signal aborts, pi's normal path gets one second to settle (it takes well under that when the tree is gone) before the wrapper rejects with pi's own "aborted" error, which the bash tool reports as "Command aborted" and the `!` executor as a cancelled run. Output that arrives after the release is dropped instead of being appended to a result that has already been finalized. The unreachable process itself keeps running; killing it needs an upstream change. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(chat): say when a steering message is delivered (agegr#647) The Steer button's tooltip promised to "interrupt the current run and inject this message now". Steering does not interrupt anything: pi queues the message and delivers it after the current assistant response and its tool calls finish, before the next model call (pi docs rpc-commands.md, sdk.md). A message steered during a long Python run therefore waits for the script, which the tooltip gave no reason to expect. Describe the real timing and point to Stop, which is what interrupts the running tool calls. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(bash): release a timed-out command the same way as a stopped one (agegr#647) pi's `timeout` kills the process tree and then waits on the inherited output handles exactly like Stop does, so a descendant the kill cannot reach kept the tool call pending past its timeout with no "Command timed out" result. The wrapper now also releases the command one grace period after the timeout, with pi's own `timeout:<seconds>` error. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 8, 2026
…gegr#1016) * fix(bash): let Stop end a command whose output a survivor holds open (agegr#647) On Stop, pi's local shell backend kills the command's process tree (process-group SIGKILL on POSIX, `taskkill /T` on Windows) and then waits for every inherited stdout/stderr handle to fall idle, re-arming a 100ms grace timer on each chunk (waitForChildProcess, earendil-works/pi#5303). A descendant the kill cannot reach keeps that wait alive for as long as it writes: a process in its own session on POSIX, or an orphan whose parent already exited on Windows, which `taskkill /T` cannot follow (earendil-works/pi#9129). The bash tool call then never returns, so the Stop request, the Stop button and any queued steering all wait until the script finishes on its own. Pi Web already routes agent and `!` shell commands through its own BashOperations wrapper, so it now bounds that wait there: once the signal aborts, pi's normal path gets one second to settle (it takes well under that when the tree is gone) before the wrapper rejects with pi's own "aborted" error, which the bash tool reports as "Command aborted" and the `!` executor as a cancelled run. Output that arrives after the release is dropped instead of being appended to a result that has already been finalized. The unreachable process itself keeps running; killing it needs an upstream change. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(chat): say when a steering message is delivered (agegr#647) The Steer button's tooltip promised to "interrupt the current run and inject this message now". Steering does not interrupt anything: pi queues the message and delivers it after the current assistant response and its tool calls finish, before the next model call (pi docs rpc-commands.md, sdk.md). A message steered during a long Python run therefore waits for the script, which the tooltip gave no reason to expect. Describe the real timing and point to Stop, which is what interrupts the running tool calls. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(bash): release a timed-out command the same way as a stopped one (agegr#647) pi's `timeout` kills the process tree and then waits on the inherited output handles exactly like Stop does, so a descendant the kill cannot reach kept the tool call pending past its timeout with no "Command timed out" result. The wrapper now also releases the command one grace period after the timeout, with pi's own `timeout:<seconds>` error. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Fixes #647
Problem
Stop could not end a bash tool call running scripts until they finished, and a steering message sent meanwhile waited for them too.
pi's local shell backend kills the command's process tree on abort (process-group SIGKILL on POSIX,
taskkill /Ton Windows) and then waits for every inherited stdout/stderr handle to fall idle, re-arming a 100ms grace on each chunk (waitForChildProcess). A descendant the kill cannot reach (its own session on POSIX, or on Windows an orphan whose parent already exited, earendil-works/pi#9129) keeps that wait alive for as long as it writes. The tool call never returns, soAgentSession.abort()and the Stop request hang. Reproduced on macOS: with an escaped writer, Stop returned only when the script ended.Separately, the Steer tooltip promised to "interrupt the current run and inject this message now". pi actually delivers a steering message after the current response and its tool calls finish, so a steer sent during a long script waits for it.
(On Windows, pi 0.84.3, which Pi Web shipped when this was reported, could also fail to spawn
taskkillat all, earendil-works/pi#6596; that is fixed by the SDK upgrade already on main.)Changes
createProjectCommandBashOperations(used for agent bash and!commands) bounds the post-abort wait: pi's own abort path gets 1s to settle, after which the wrapper rejects with pi'sabortederror ("Command aborted" / a cancelled!run). Output arriving after the release is dropped. The normal abort path is unchanged.Not covered: processes the kill cannot reach keep running (needs an upstream Job Object change, earendil-works/pi#9129); the Windows
powershelltool uses pi's operations directly.Testing
node --experimental-strip-types --test lib/project-command-env.test.mjs: new tests for a stuck backend released after the grace, pi's own abort result passing through untouched, and a realdetachedwriter holding stdout no longer blocking the bash tool (POSIX). Both survivor tests time out without the fix.lib/rpc-manager*.test.mjs,lib/subagent*.test.mjs,lib/i18n/registry.test.mjs,components/ChatInput.test.mjspass;tsc --noEmitand eslint clean.🤖 Generated with Claude Code