Forward repeated signals through the npm wrapper (#61221)

## Why

The npm wrapper's spawn fallback stopped forwarding signals after the first one, preventing a second signal from interrupting a child's graceful shutdown.

## What changed

Remove the `child.killed` guard so the wrapper continues forwarding `SIGINT`, `SIGTERM`, and `SIGHUP` until the child exits.

## Testing

Add a regression test that forces the spawn fallback and verifies a running child receives a second `SIGTERM` and its numeric exit status is preserved.

GitOrigin-RevId: be96e784e2e4f419c43a5897d264f55fcdfd625f
This commit is contained in:
Eric Traut
2026-11-13 01:21:09 +00:00
committed by copyberry
parent e1340f2ea8
commit 662daabad2
2 changed files with 50 additions and 22 deletions
+2 -7
View File
@@ -258,14 +258,9 @@ child.on("error", (err) => {
process.exit(1);
});
// Forward common termination signals to the child so that it shuts down
// gracefully. In the handler we temporarily disable the default behavior of
// exiting immediately; once the child has been signaled we simply wait for
// its exit event which will in turn terminate the parent (see below).
// Keep forwarding signals until the child exits so a second signal can
// interrupt a graceful shutdown.
const forwardSignal = (signal) => {
if (child.killed) {
return;
}
try {
child.kill(signal);
} catch {