Stop cannot kill the CLI: killForcibly is a finalizer, and the stdout read it would unblock is not interruptible #75
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
iterative-works/claude-code-query#75
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Reported from procedures, where a dashboard's Stop control drives claude-code-query 0.6.0.
Measured on a running harness against a stand-in CLI that stays silent:
Chain, in zio/src/works/iterative/claude/zio/internal/cli/ProcessManager.scala:
So the kill that would make the pipes hit EOF is waiting for the read that only the kill can unblock. The comment at the finalizer says 'killing the process makes the pipes hit EOF, letting the forked readers finish promptly' — true, but the kill never gets to run.
Consequence for a consumer: a query cannot be cancelled. For an interactive agent that means a Stop button that stops nothing, and a subprocess that keeps spending tokens and making tool calls with nobody watching.
Possible directions (not investigated in depth): kill the process on the interrupt signal rather than in scope teardown (ZIO.onInterrupt beside the stream, or an uninterruptible mask around a supervisor that kills first), or read stdout through an interruptible blocking read.
Found while closing cc-chat/06-gladys-global-chat. The consumer fixed its own half — the interruption was not reaching the work at all (procedures 39010372); this is what remains, and it is a 0.6.1 matter.
A related wait that only a kill can end, on a different path, is filed as #83: a session whose stdout reader fails while the CLI lives goes to recordEnd, which waits on process.waitFor with nobody reading stdout (zio/src/works/iterative/claude/zio/internal/cli/SessionProcess.scala:166-169; the same shape in the Kyo adapter). Found closing kyo-experiment/02-kyo-session.