-
Notifications
You must be signed in to change notification settings - Fork 247
cross-env should exit with non-zero code when terminated by Ctrl-C (SIGINT) #228
Comments
Does this PR fix this problem? #227 |
Yes, it should fix this problem. The code in #227 works when However, when only the parent process receives the signal (e.g., after I commented about this on the PR, too. |
On Windows, using Git for Windows bash:
It depends on what cat does when receiving a SIGINT as to what cross-env will do. |
I wasn't able to work out how to emulate https://unix.stackexchange.com/questions/149741/why-is-sigint-not-propagated-to-child-process-when-sent-to-its-parent-process on windows. The I've aliased
If I use node directly, the
|
This should be fixed now :) |
Steps to reproduce:
Run a shell command like this:
The
cat
process is waiting for stdin and therefore keeps running. Now terminate the command with Ctrl-C.Expected result:
The
cross-env cat
command didn't succeed -- it was terminated before it has a chance to finish. Therefore, theecho success
command shouldn't run and shouldn't writesuccess
to console.Actual result:
The
cross-env
's child process exits because it was terminated by a signal, andcross-env
then exits itself with error code 0. That means success and theecho success
command gets to run.Proposed solution:
Basically, #181 by @jnielson94 should be reverted. On SIGINT, the exit code should be 128 + signal_number, i.e., 130. Shell will do such a translation, as documented for example here. And it can be verified by a simple experiment in your shell:
I'm not sure I understand what exactly is reported as wrong in @jnielson94's #180 report. That the script errors when terminated with Ctrl-C and that
npm run
logs an error? However, I believe that's actually the correct behavior 🙂 It's what makes shell conditional chains (cmd1 && cmd2
,cmd3 || cmd4
) work.The text was updated successfully, but these errors were encountered: