Background Bash tasks on Windows/Git Bash stay stuck as 'running' after the command has finished

Open 💬 0 comments Opened Jul 5, 2026 by yagodev-coder

Environment

  • OS: Windows 11 Pro (build 10.0.26200)
  • Shell: Git Bash (MSYS2), invoked as the Bash tool's shell
  • Claude Code version: 2.1.197
  • Entrypoint: claude-desktop

Bug description

When a Bash tool call gets auto-promoted to a background task (e.g. because it doesn't return within the default timeout), the "Tarefas em segundo plano" / "Background tasks" panel keeps showing it under "Em execução" / "Running" indefinitely, even though the underlying command has already finished and written its output to disk.

Example command that triggered it:

.venv/Scripts/python.exe -m pytest -q > /tmp/pytest_out8.txt 2>&1; cygpath -w /tmp/pytest_out8.txt
  • The redirected output file (/tmp/pytest_out8.txt) already contained the final pytest result ("51 passed in 8.43s") well before the panel updated.
  • The panel still showed the task as running with "Sem saída ainda" / "No output yet" after 10+ minutes.
  • Querying the task via the internal task-output mechanism confirmed the backend itself still considered the task status: running (not just a stale UI card) — the shell process appears to not signal completion back to the app.
  • This has happened repeatedly across several background Bash invocations in the same session, not a one-off.
  • Manually stopping the task resolved it and removed it from the panel.

Expected behavior

Once the underlying shell command exits (and its output file is fully written), the background task panel should reflect the task as completed/finished, not remain stuck as "running".

Suspected cause

Likely related to how the Git Bash / MSYS2 shell process on Windows reports (or fails to report) process exit back to the Claude Code background-task tracker — possibly a pty/process-handle cleanup issue specific to Windows.

View original on GitHub ↗