Conversation
When cmd-shim is used in pnpm to create a wrapper for "node", you cannot kill the node process by killing the process spawned by invoking node_modules/.bin/node, because the binstub doesn't use 'exec'. Commit 1033be3 ("fix: improve sh binstubs", 2020-01-16) added 'exec' to the "shLongProg" code path, but for some reason didn't add it to the non-"shLongProg" path. Add it in the "shLongProg" case to fix the issue of killing node.
There was a problem hiding this comment.
Pull request overview
This PR fixes POSIX sh binstub generation so the shim uses exec even when the “long program path” (shLongProg) branch is not taken, allowing signals (e.g., kill) to correctly reach the underlying node process.
Changes:
- Add
execto the non-shLongProgbranch ingenerateShShim()so the shim process is replaced by the target process. - Update JS snapshot expectations for generated shims to include
exec.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/index.ts |
Ensures generated sh shim uses exec in the non-shLongProg path so signals propagate correctly. |
test/test.js.snapshot |
Updates snapshots to match the new exec-prefixed sh shim output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
485
to
496
| if (shLongProg) { | ||
| sh += `\ | ||
| if [ -x ${shLongProg} ]; then | ||
| exec ${shLongProg} ${args} ${shTarget} ${progArgs}"$@" | ||
| else | ||
| exec ${shProg} ${args} ${shTarget} ${progArgs}"$@" | ||
| fi | ||
| ` | ||
| } else { | ||
| sh += `\ | ||
| ${shProg} ${args} ${shTarget} ${progArgs}"$@" | ||
| exec ${shProg} ${args} ${shTarget} ${progArgs}"$@" | ||
| exit $? |
There was a problem hiding this comment.
PR description says the missing exec is in the "shLongProg" code path, but this change actually adds exec to the non-shLongProg (else) branch. Consider updating the PR description to match the implementation so future readers understand which path was fixed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When cmd-shim is used in pnpm to create a wrapper for "node", you cannot kill the node process by killing the process spawned by invoking node_modules/.bin/node, because the binstub doesn't use 'exec'.
Commit 1033be3 ("fix: improve sh binstubs", 2020-01-16) added 'exec' to the "shLongProg" code path, but for some reason didn't add it to the non-"shLongProg" path.
Add it in the "shLongProg" case to fix the issue of killing node.