Skip to content

Instantly share code, notes, and snippets.

@markhuge
Created November 7, 2014 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markhuge/fe5572ad1e98f723445b to your computer and use it in GitHub Desktop.
Save markhuge/fe5572ad1e98f723445b to your computer and use it in GitHub Desktop.
var http = require('http');
console.log(process.pid);
http.createServer().listen(9001);
process.on('SIGINT', function () {
console.log('I totally caught this and won\'t exit');
});
  • When this app is started with node index, a SIGINT (Ctrl+c) is caught by the app and it continues running.
  • When this app is started with npm start, a SIGINT causes npm to exit, detaching the still running node process from the foreground.
{
"name": "example",
"scripts": {
"start": "node index"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment