Created
August 16, 2018 10:27
-
-
Save mgdelacroix/0c26007ef14940fede1ff77ad715dcfa to your computer and use it in GitHub Desktop.
Simple proof of concept for nodejs SIGINT capture
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
let waiting = false | |
process.on('SIGINT', () => { | |
console.log('CTRL+C detected!') | |
if (!waiting) { | |
waiting = true | |
} else { | |
console.log('Was waiting, so exiting now') | |
process.exit(0) | |
} | |
setTimeout(() => process.exit(0), 2000) | |
}) | |
setTimeout(() => { | |
console.log('WAITING FINISHED') | |
}, 100000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment