Skip to content

Exit with 130 after receiving SIGINT #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Conversation

isaacl
Copy link

@isaacl isaacl commented Jul 31, 2025

pnpm should exit with non-zero code when aborting
abnormally due to SIGINT

Fixes: pnpm/pnpm#9626

@isaacl
Copy link
Author

isaacl commented Aug 1, 2025

I pushed an update, which should fix the tests

pnpm should exit with non-zero code when aborting
abnormally due to SIGINT

Fixes: pnpm/pnpm#9626
@zkochan
Copy link
Member

zkochan commented Aug 2, 2025

Does this work the same in npm CLI? Can you verify by finding the related code in npm CLI?

@isaacl
Copy link
Author

isaacl commented Aug 3, 2025

@zkochan re: npm behavior

Well ... this PR makes the behavior closer. Right now, in the most common case -- Ctrl-C in an interactive shell -- npm exits with 130, while pnpm exits with 0.

$ npm run sleep &>/dev/null &; sleep .5; kill -INT %1; wait $!; echo $?
130
$ pnpm run sleep &>/dev/null &; sleep .5; kill -INT %1; wait $!; echo $?
0

While npm is running a script, it captures SIGINT and relays to children, similar to pnpm.

npm does not track when its traps activate.

But, if a child dies by signal -- npm sends this signal to self (run-script-pkg.js) (pnpm does this too ... but not with SIGINT).

If the goal is purely consistency with NPM, one could simply roll back #41

@zkochan
Copy link
Member

zkochan commented Aug 4, 2025

In that case maybe we should roll back #41

@isaacl
Copy link
Author

isaacl commented Aug 10, 2025

In that case maybe we should roll back #41

Yes, agreed. I've moved the small other suggestions to #51


BTW: this origin of this issue is from a project I work on that has package.json scripts like pnpm run test:ct && pnpm run test:e2e. Hitting Ctrl-C does not abort as expected because the first pnpm instance exits with 0.

@isaacl isaacl closed this Aug 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pnpm run emits incorrect exit code when interrupted
2 participants