feat(npm): forward termination signals to child process #12441
Merged
+27
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This improves on the current process termination flow for running foundry tools through node/npm.
Without the fix, the wrapper swallows
SIGINT/SIGTERM: the parent exits with 0 and the child gets aSIGTERM, so callers can’t tell a tool was interrupted and the tool never sees Ctrl+C. Forwarding the exact signal and then re‑emitting it locally restores the original behavior. Tools handle signals themselves and the wrapper exits with the standard130/143codes.How I verified this:
/tmp/test.mjs:^ should print
exit code: 130. Replacekill -INT "$PID"withkill -TERM "$PID", should see143instead of130.Example where this matters: GitHub Actions runners.
When cancelling a job (or the platform aborts it for timing out), it sends
SIGINTorSIGTERMto every process. Before this fix the Foundry npm wrapper would catch that signal, kill the child with a plainSIGTERM, and then exit with status 0. GitHub interprets 0 as success, so the workflow step looks green even though it was canceled midway.With this change, the wrapper exits with 130/143, so CI marks the step as “canceled” or “failed” as it should, and downstream steps/devices don’t keep running on a half-finished build.