Created
September 7, 2012 21:14
-
-
Save terrancesnyder/3669704 to your computer and use it in GitHub Desktop.
Handling Ctrl-C cleanly in Node.js
This file contains hidden or 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
// 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