fix(cli): prevent double SIGTERM dispatch when both SIGINT and SIGTERM arrive

The forward handler now self-removes both listeners before calling
killProcessTree, so a second signal cannot invoke it again on an
already-dead PID.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Priyanshu Choudhary 2026-04-08 16:51:21 +05:30
parent ec3349454b
commit d96a11a1c7
1 changed files with 2 additions and 0 deletions

View File

@ -1148,6 +1148,8 @@ async function runStartup(
// SIGINT/SIGTERM so the dashboard group is also cleaned up on exit.
if (!isWindows() && pid) {
const forward = (): void => {
process.off("SIGINT", forward);
process.off("SIGTERM", forward);
void killProcessTree(pid, "SIGTERM");
};
process.once("SIGINT", forward);