fix(cli): complete cleanup after relayed interrupts (#1202)
* fix: Handle relayed SIGINT gracefully in withProcessCancellation Changes `process.once` to `process.on` for SIGINT in `DirectAnalysis.ts`. When REA is launched via npx, a single process-group SIGINT triggers two SIGINT events (one direct, one relayed). Previously, the first event would consume the handler and the second would abruptly terminate the Node process, abandoning Ghidra resource cleanup. This change ensures subsequent SIGINTs idempotently request cancellation without crashing the process, matching the behaviour of `withCommandCancellation`. * fix(cli): keep termination guards through provider cleanup * test(cli): exercise repeated analysis signals on macOS --------- Co-authored-by: N0zoM1z0 <1705004398@qq.com>
This commit is contained in:
co-authored by
N0zoM1z0
parent
0fec65d06b
commit
911152a04d
@@ -68,12 +68,14 @@ describe("one-shot analysis factory boundary", () => {
|
||||
const [path] = await createBinarySessionTargets();
|
||||
const failure = new Error("fixture execution failed");
|
||||
const factories = recordingFactories(failure);
|
||||
const listeners = process.listenerCount("SIGINT");
|
||||
const interruptListeners = process.listenerCount("SIGINT");
|
||||
const terminateListeners = process.listenerCount("SIGTERM");
|
||||
await expect(
|
||||
runDirectAnalysis(factories.dependencies, path, "read_bytes", {}),
|
||||
).rejects.toBe(failure);
|
||||
expect(factories.clientsClosed()).toBe(1);
|
||||
expect(process.listenerCount("SIGINT")).toBe(listeners);
|
||||
expect(process.listenerCount("SIGINT")).toBe(interruptListeners);
|
||||
expect(process.listenerCount("SIGTERM")).toBe(terminateListeners);
|
||||
expect(factories.sessions[0]?.activeTarget()).toBeUndefined();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user