[PR #1202] [MERGED] fix(cli): complete cleanup after relayed interrupts #2716

Closed
opened 2026-10-17 21:09:25 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1202
Author: @Sravan1011
Created: 10/9/2026
Status: ✅ Merged
Merged: 10/9/2026
Merged by: @N0zoM1z0

Base: main ← Head: fix/npx-sigint-relay


📝 Commits (3)

  • 85ff489 fix: Handle relayed SIGINT gracefully in withProcessCancellation
  • 64a3ccf fix(cli): keep termination guards through provider cleanup
  • ad2388d test(cli): exercise repeated analysis signals on macOS

📊 Changes

6 files changed (+174 additions, -7 deletions)

View changed files

📝 .github/workflows/ci.yml (+1 -1)
📝 docs/mcp-contracts.md (+5 -3)
📝 src/application/DirectAnalysis.ts (+5 -1)
➕ tests/boundary/process/directAnalysisSignals.test.ts (+78 -0)
📝 tests/composition/directAnalysisFactories.test.ts (+4 -2)
➕ tests/fixtures/directAnalysisInterrupt.mjs (+81 -0)

📄 Description

Interrupting native analysis through npx can deliver SIGINT twice: directly from the terminal group and again from the package runner. The first delivery removed REA's one-shot handler, so the second could terminate it during provider cleanup and leave an owned Ghidra JVM and runtime directory. Fixes #1191.

Keep SIGINT and SIGTERM guards installed until the direct, native, or managed analysis call finishes cleanup, then remove both listeners. Caller-supplied AbortSignals retain their existing behavior. Add process-level regressions that interrupt all three entry paths again while cleanup is blocked, verify typed cancellation, and check that listeners are released after success or failure.

Validation:

  • The six new signal regressions fail on the affected main baseline; all 23 focused signal, factory, and snapshot tests pass with the fix.
  • Built CLI / Linux x64 / Ghidra 12.1.4: reproduced an orphaned JVM before the fix and verified no owned JVM or Ghidra runtime remains afterward. The npx probe sends one group SIGINT while briefly pausing npm's forwarder to separate its relayed delivery deterministically. The direct-process control also returns cancelled with cleanup: complete.
  • npm run build:cached and npm run check:fast passed. Native macOS Ghidra was not executed locally; CI covers the deterministic macOS process tests.

No public schema or tool inventory change. Existing provider ownership checks remain in charge of stopping resources.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/1202 **Author:** [@Sravan1011](https://github.com/Sravan1011) **Created:** 10/9/2026 **Status:** ✅ Merged **Merged:** 10/9/2026 **Merged by:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Base:** `main` ← **Head:** `fix/npx-sigint-relay` --- ### 📝 Commits (3) - [`85ff489`](https://github.com/morluto/rea/commit/85ff48963ccf8dffefd78473d68bbc1ffbf2fe7e) fix: Handle relayed SIGINT gracefully in withProcessCancellation - [`64a3ccf`](https://github.com/morluto/rea/commit/64a3ccfc2945e2d3b93e052d1b7ec4e5bc9c0b15) fix(cli): keep termination guards through provider cleanup - [`ad2388d`](https://github.com/morluto/rea/commit/ad2388d5a0654723aac096b66218651dd07eb3d9) test(cli): exercise repeated analysis signals on macOS ### 📊 Changes **6 files changed** (+174 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/ci.yml` (+1 -1) 📝 `docs/mcp-contracts.md` (+5 -3) 📝 `src/application/DirectAnalysis.ts` (+5 -1) ➕ `tests/boundary/process/directAnalysisSignals.test.ts` (+78 -0) 📝 `tests/composition/directAnalysisFactories.test.ts` (+4 -2) ➕ `tests/fixtures/directAnalysisInterrupt.mjs` (+81 -0) </details> ### 📄 Description Interrupting native analysis through `npx` can deliver SIGINT twice: directly from the terminal group and again from the package runner. The first delivery removed REA's one-shot handler, so the second could terminate it during provider cleanup and leave an owned Ghidra JVM and runtime directory. Fixes #1191. Keep SIGINT and SIGTERM guards installed until the direct, native, or managed analysis call finishes cleanup, then remove both listeners. Caller-supplied AbortSignals retain their existing behavior. Add process-level regressions that interrupt all three entry paths again while cleanup is blocked, verify typed cancellation, and check that listeners are released after success or failure. Validation: - The six new signal regressions fail on the affected main baseline; all 23 focused signal, factory, and snapshot tests pass with the fix. - Built CLI / Linux x64 / Ghidra 12.1.4: reproduced an orphaned JVM before the fix and verified no owned JVM or Ghidra runtime remains afterward. The `npx` probe sends one group SIGINT while briefly pausing npm's forwarder to separate its relayed delivery deterministically. The direct-process control also returns `cancelled` with `cleanup: complete`. - `npm run build:cached` and `npm run check:fast` passed. Native macOS Ghidra was not executed locally; CI covers the deterministic macOS process tests. No public schema or tool inventory change. Existing provider ownership checks remain in charge of stopping resources. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-17 21:09:25 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#2716
No description provided.