gemini-cli
gemini-cli copied to clipboard
Add background process tracking support for Windows in shell tool
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:
- Use Windows Job Objects or WMI to track child processes
- Implement a Windows-equivalent of the pgrep functionality
- 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