Skip to content

fix: terminate child processes when the status line is cancelled - #61

Open
LairdLuca wants to merge 1 commit into
daniel3303:mainfrom
LairdLuca:fix/windows-suspended-git-processes
Open

LairdLuca wants to merge 1 commit into
daniel3303:mainfrom
LairdLuca:fix/windows-suspended-git-processes

Conversation

@LairdLuca

Copy link
Copy Markdown

Fixes #60

Change

  • The script now places itself in a job object with JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE, so Windows terminates its children when it dies, including a child still suspended. It uses Reflection.Emit rather than Add-Type, because Add-Type compiles with csc.exe and would add another child process and a noticeable delay.
  • Both git calls now use --no-optional-locks, so a git process killed mid-run cannot leave a stale index.lock behind.

If the job cannot be created, the script carries on as before.

Testing

On Windows 11, Windows PowerShell 5.1, git 2.55.0.windows.5:

Check Before After
Suspended git left after killing the script 4 of 60 runs 0 of 100 runs
Slow child process still alive after killing the script yes no
Output for the same JSON input n/a byte-identical to v1.4.5

In real use with about 9 Claude Code sessions open, no status line git process was left suspended in 4 hours 20 minutes. The rate before the fix was about 16 per hour.

Not tested: PowerShell 7 (not installed on my machine). statusline.sh is unchanged.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GXnnyDw7DGcUjXnZRuXNKL

Claude Code cancels an in-flight status line when a new update arrives.
On Windows, a parent killed while creating a child leaves that child
suspended forever, so git.exe processes pile up. Run the script in a
kill-on-close job object so Windows terminates its children with it, and
pass --no-optional-locks so a killed git cannot leave a stale index.lock.

Fixes daniel3303#60

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GXnnyDw7DGcUjXnZRuXNKL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: cancelled status line leaves git processes suspended forever

1 participant