Created
February 16, 2019 12:22
-
-
Save jsmrcaga/c84236eece0c27baffec28e79896d4a4 to your computer and use it in GitHub Desktop.
This file contains 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
// INSTRUCTIONS | |
/* | |
* 1) Run node sigint.js and call ctrl-c, then wait 1 second (for process to exit) | |
* Expected output: SIGINT 1 | |
* | |
* 2) Run npm start (see end of file for example, which runs node sigint.js) and call ctrl-c, then wait 1 second (for process to exit) | |
* Expected output SIGINT 1 | |
* Unexpected output SIGINT 2 | |
*/ | |
let called = 0; | |
// do not auto kill | |
setTimeout(() => {}, 1000000); | |
process.on('SIGINT', () => { | |
console.log('SIGINT', ++called); | |
setTimeout(() => { | |
process.exit(0); | |
}, 1000); | |
}); | |
// NPM package.json example | |
// here for accessibility purposes | |
// { | |
// "scripts": { | |
// "start": "node sigint.js" | |
// } | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment