Skip to content

Instantly share code, notes, and snippets.

@mgdelacroix
Created August 16, 2018 10:27
Show Gist options
  • Save mgdelacroix/0c26007ef14940fede1ff77ad715dcfa to your computer and use it in GitHub Desktop.
Save mgdelacroix/0c26007ef14940fede1ff77ad715dcfa to your computer and use it in GitHub Desktop.
Simple proof of concept for nodejs SIGINT capture
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