I tried searching the Node.js source code, but I could not find it. By default, where would I find the Node.js code that handles SIGINT (Ctrl-c) by default in the following example:
var http = require('http');
var server = http.createServer(function(req, res) {
res.writeHead(200);
res.end('Hello Http');
});
server.listen(5001);
Node's default SIGINT handler is in node.cc, but it doesn't do much. It calls signalExit, which does
uv_tty_reset_mode();
_exit(1);
You can add your own handler in node.js with
process.on('SIGINT', function () {
// handle
});
You have to add it yourself. http://nodejs.org/api/process.html#process_signal_events
process.on('SIGINT', function () {
//do stuff here.
});