gemini-cli - 💡(How to fix) Fix Raw signal shutdown does not validate persistence [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
google-gemini/gemini-cli#27281Fetched 2026-05-20 03:59:28
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
labeled ×2

Code Example

async function gracefulShutdown(_reason: string) {
    if (isShuttingDown) {
      return;
    }
    isShuttingDown = true;

    await runExitCleanup();
    process.exit(ExitCodes.SUCCESS);
  }

---

process.on('SIGHUP', () => gracefulShutdown('SIGHUP'));
  process.on('SIGTERM', () => gracefulShutdown('SIGTERM'));
  process.on('SIGINT', () => gracefulShutdown('SIGINT'));

---

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                                                 │
About Gemini CLI│                                                                                                                                                                                                                                                                                 │
CLI Version                                                                                    0.42.0Git Commit                                                                                     68e2196d5                                                                                                                                                                        │
Model                                                                                          Auto (Gemini 3)Sandbox                                                                                        no sandbox                                                                                                                                                                       │
OS                                                                                             linux                                                                                                                                                                            │
Auth Method                                                                                    Signed in with GoogleTier                                                                                           Gemini Code Assist in Google One AI Pro│                                                                                                                                                                                                                                                                                 │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
RAW_BUFFERClick to expand / collapse

What happened?

Interactive Ctrl+C is usually handled by the UI and can route to /quit on the second press. But raw SIGINT, SIGTERM, and SIGHUP are also registered. That path runs runExitCleanup() and exits. It does not validate whether the current session file is complete or resumable. It does not flush any higher-level recording state beyond already-synchronous writes. If the process is interrupted around initialization or recording failure, the session can be left incomplete.

packages/cli/src/utils/cleanup.ts:135

async function gracefulShutdown(_reason: string) {
   if (isShuttingDown) {
     return;
   }
   isShuttingDown = true;

   await runExitCleanup();
   process.exit(ExitCodes.SUCCESS);
 }

packages/cli/src/utils/cleanup.ts:145

  process.on('SIGHUP', () => gracefulShutdown('SIGHUP'));
  process.on('SIGTERM', () => gracefulShutdown('SIGTERM'));
  process.on('SIGINT', () => gracefulShutdown('SIGINT'));

What did you expect to happen?

Signal shutdown should perform a best-effort session integrity check. If the file is metadata-only, missing metadata, or recording was disabled, the CLI should not later imply that it was a healthy saved session. Any cleanup should avoid deleting very recent incomplete files. The shutdown path should preserve recoverability wherever possible.

Client information

<details> <summary>Client Information</summary>

Run gemini to enter the interactive CLI, then run the /about command.

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                                                 │
│ About Gemini CLI                                                                                                                                                                                                                                                                │
│                                                                                                                                                                                                                                                                                 │
│ CLI Version                                                                                    0.42.0                                                                                                                                                                           │
│ Git Commit                                                                                     68e2196d5                                                                                                                                                                        │
│ Model                                                                                          Auto (Gemini 3)                                                                                                                                                                  │
│ Sandbox                                                                                        no sandbox                                                                                                                                                                       │
│ OS                                                                                             linux                                                                                                                                                                            │
│ Auth Method                                                                                    Signed in with Google                                                                                                                       │
│ Tier                                                                                           Gemini Code Assist in Google One AI Pro                                                                                                                                          │
│                                                                                                                                                                                                                                                                                 │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
</details>

Login information

Signed in with Google

Anything else we need to know?

No response

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

gemini-cli - 💡(How to fix) Fix Raw signal shutdown does not validate persistence [1 participants]