Gemini CLI patch fixes headless interruption: orphaned shells, exit codes, lost tool calls
Vara715 · ghdev · 2026-10-30
PR #30051 in google-gemini/gemini-cli fixes what happens when a headless run (gemini -p ... --yolo) is interrupted by Ctrl+C or a signal while runshellcommand is active:
- Wrong exit codes: the process exited with code 0 instead of standard signal codes; now SIGINT→130, SIGTERM→143, SIGHUP→129.
- Orphaned shells: spawned commands survived in a detached process group and ran to completion in the background. A new cleanupAllActiveProcesses() terminates active child processes and PTY groups cross-platform (taskkill on Windows, group signals on POSIX).
- Lost session records: session-.jsonl omitted the interrupted tool call, so --resume latest had no trace. Tool calls are now persisted with status Scheduled as soon as the stream yields them, and on resume an interrupted functionResponse is synthesized—preventing Gemini API 400 errors from unpaired function calls and letting the model inspect state before re-running.
Shared helpers like createCancelledToolCall moved into @google/gemini-cli-core for consistent cancellation handling. Fixes #30007, with unit tests and validation steps included.
More from coding & agent
- Tangled launches as the first federated code forge built on AT Protocol — itsarnavb · 2026-10-31
- Google's free open-source repo lets Claude Code or Cursor drive a real Android phone — victor_explore · 2026-10-31
- Signal65: Snowflake's CoCo agent finishes workflow 4.6x faster than manual — ryanshrout · 2026-10-31
- OpenRouter team launches OpenCommerce: one API to buy from 5,000+ stores for agents — ycombinator · 2026-10-31
- YC's Garry Tan: AI turns code into a rushing river—much of software must be rewritten — garrytan · 2026-10-31
- A petting-zoo prompt ballooned into a 15,969-line 3D open world — jacalulu · 2026-10-31