Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Handling Ctrl-C cleanly in Node.js
// Show how to handle Ctrl+C in Node.js
var zmq = require('zmq')
, socket = zmq.createSocket('rep');
socket.on('message', function(buf) {
// echo request back
socket.send(buf);
});
process.on('SIGINT', function() {
socket.close();
process.exit();
});
socket.bindSync('tcp://*:5555');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment