Skip to content
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

Node-dev does not send SIGTERM on CTRL+C #291

Open
macjabeth opened this issue Apr 21, 2022 · 1 comment
Open

Node-dev does not send SIGTERM on CTRL+C #291

macjabeth opened this issue Apr 21, 2022 · 1 comment

Comments

@macjabeth
Copy link

My package.json script uses the node-dev CLI to run code with the event listener:

process.on('SIGTERM', () => {
  console.log('SIGTERM fired...');
});

When I use CTRL+C to halt the server, I get no console notifications.

This should be handled so we can properly exit node-dev servers with CTRL+C. Thank you!

@bjornstar
Copy link
Collaborator

From https://nodejs.org/api/process.html#signal-events

'SIGTERM' and 'SIGINT' have default handlers on non-Windows platforms that reset the terminal mode before exiting with code 128 + signal number. If one of these signals has a listener installed, its default behavior will be removed (Node.js will no longer exit).

If you add a SIGTERM handler, you are expected to shutdown the process yourself either by calling process.exit or removing all listeners.

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

No branches or pull requests

2 participants