fix(jobs): kill the whole process group on /cursor:cancel - #17
Merged
Conversation
Background jobs run as a detached worker (own process group) that spawns cursor-agent as a plain child. cancelJob() signalled only the worker pid, so the worker died but cursor-agent kept running — still editing files and consuming credits — while /cursor:status reported the job as cancelled. - new lib/kill.mjs#killTree: POSIX kill(-pid) with single-pid fallback for foreground jobs whose recorded pid is not a group leader; taskkill /T /F on Windows - cancelJob uses killTree for both the SIGTERM and the post-grace SIGKILL - tests: killTree unit tests + a jobs test reproducing the detached worker + child shape, asserting both processes die on cancel Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
freema
commented
Jul 28, 2026
freema
left a comment
Owner
Author
There was a problem hiding this comment.
CodeForge Review
Verdict: comment | Score: 0/10
{
"verdict": "comment",
"score": 7,
"summary": "Solid, well-documented fix for the cursor-agent orphaning bug (setsid + kill(-pgid), with sane Windows/fallback handling and good test coverage).
[Session timed out after 300s. Partial output above.]
---
*Reviewed by [CodeForge](https://github.com/freema/codeforge)*
This was referenced Jul 28, 2026
freema
added a commit
that referenced
this pull request
Jul 28, 2026
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
/cursor:cancelkilled only the detached worker process, orphaning thecursor-agentchild it had spawned. The orphan kept editing files and consuming Cursor credits while/cursor:statusreported the job ascancelled.Root cause:
spawnBackground()starts the worker withdetached: true(its own process group,delegate.mjs/review.mjs), the worker spawnscursor-agentas a plain child (same group), butcancelJob()signalled onlyjob.pid.Changes
scripts/lib/kill.mjs#killTree(pid, signal):kill(-pid)to reach the whole group; falls back to a single-pid kill when the recorded pid is not a group leader (the foreground-job case), matching the old behaviour there.taskkill /PID <pid> /T /F.cancelJob()useskillTreefor both the initial SIGTERM and the post-grace SIGKILL.killadded to the lib list in AGENTS.md.Test plan
tests/kill.test.mjs: pid validation, single-pid fallback for a non-group-leader,falsewhen nothing answers.tests/jobs.test.mjsreproducing the exact background shape (detached group-leader worker + long-running child): cancel must kill both processes. Skipped on win32.npm test: 93/93 green.npm run lint: clean.