OS: Windows 11
node –version: v21.7.3 (also tested with other versions, 18.20.3)
index.js:
// to create the event loop
const timer = setInterval(() => {
console.log('hello');
}, 2500);
console.log('hi!');
process.on('SIGTERM', () => {
console.log('got SIGTERM');
clearInterval(timer);
});
process.on('SIGINT', () => {
console.log('got SIGINT');
clearInterval(timer);
});
Running node --watch --watch-preserve-output index.js
Then I update the file and expect to see got SIGTERM
output, but I don’t get it.
Restarting 'test-node.js'
updated hi!
The thing is that it works on https://stackblitz.com/edit/node-qv37ky?file=index.js
Restarting 'index.js'
got SIGTERM
updated hi!
I just don’t understand why it doesn’t handle the signal on my workstation? What can be the reason for this behaviour?