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
@@ -388,11 +388,15 @@ const withProcessCancellation = async <Value>(
|
||||
if (suppliedSignal !== undefined) return operation(suppliedSignal);
|
||||
const controller = new AbortController();
|
||||
const cancel = (): void => controller.abort();
|
||||
process.once("SIGINT", cancel);
|
||||
// Package runners can forward a terminal interrupt after REA already received
|
||||
// it directly. Keep both guards installed until provider cleanup has settled.
|
||||
process.on("SIGINT", cancel);
|
||||
process.on("SIGTERM", cancel);
|
||||
try {
|
||||
return await operation(controller.signal);
|
||||
} finally {
|
||||
process.off("SIGINT", cancel);
|
||||
process.off("SIGTERM", cancel);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user