Last active
August 29, 2015 14:03
-
-
Save tj/41545c718f8a8256f8f5 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
function shutdown() { | |
var times = 0; | |
process.on('SIGINT', function(){ | |
trapped('INT'); | |
}); | |
process.on('SIGQUIT', function(){ | |
trapped('QUIT'); | |
}); | |
function trapped(sig) { | |
switch (++times) { | |
case 1: | |
console.log('signal received: %s', sig); | |
break; | |
case 2: | |
console.log('second signal received: %s', sig); | |
console.log('forcing exit'); | |
process.exit(1); | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment