gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

Add background process tracking support for Windows in shell tool

Open akhil29 opened this issue 3 months ago • 1 comments

Description

The current implementation of background process tracking in the shell tool has limited support for Windows. While Unix-like systems can track background processes using pgrep and process groups, Windows doesn't have equivalent functionality implemented.

Current Behavior

On Unix/Linux/macOS:

  • Background processes are tracked via a temp file using pgrep
  • Process groups are used to terminate all child processes
  • SIGTERM followed by SIGKILL ensures proper cleanup

On Windows:

  • Background process PIDs are not tracked (pgrep not available)
  • Only the main process can be terminated with taskkill
  • Child processes may become orphaned

Proposed Solution

Implement Windows-specific background process tracking:

  1. Use Windows Job Objects or WMI to track child processes
  2. Implement a Windows-equivalent of the pgrep functionality
  3. Ensure all child processes are terminated when cancellation occurs

Related PR

This issue was identified during the implementation of #7790 which adds cancellation support for slash commands and background processes.

Acceptance Criteria

  • [ ] Background processes launched with & are tracked on Windows
  • [ ] All child processes are terminated when the parent is cancelled
  • [ ] Tests verify Windows-specific functionality
  • [ ] Cross-platform behavior is consistent

akhil29 avatar Oct 12 '25 06:10 akhil29