title: ZMQ on NodeJS: catching errors
body: <p>I've been working with the ZMQ binding for NodeJS for a while now but I never received such error:</p>
  
  <pre><code>Error: Interrupted system call
      at Socket._ioevents (/path/node_modules/zmq/lib/index.js:144:22)
      at Socket._flush (/path/node_modules/zmq/lib/index.js:273:23)
  </code></pre>
  
  <p>Now, I have a big system that creates topologies. For me it's really difficult given such error to go and see which node of the topology screwes up. The idea is to put some kind of try / catch to catch this error and log where it happens.</p>
  
  <p>Is there a way to do this? I don't think the following code will work:</p>
  
  <pre><code>try {
      receiver.on('message', function(data){
          //do stuff  
      });
  }
  catch(e) {
      console.log("error " + e)
  }
  </code></pre>
  
  <p>Since I have to modify a huge part of the software with all these try/catch, I want to be sure if this is the right way (which I'm almost sure is not) to catch that kind of error.</p>
  
  <p>Anybody can confirm this? Otherwise anybody with experience can enlighten me on the error I'm receiving?</p>
  
  <p>Thanks</p>
  
  <p>EDIT: after a quick test I can confirm 99% this approach is not working. Is there a way in which I can get where that error comes from?</p>
  
  <p>2nd EDIT: I discovered that this problem may be related to the upgrade from version 2.0 to version 2.1 of ZMQ. This is the link to the changelog <a href="http://www.zeromq.org/docs:2-1-upgrade" rel="nofollow">http://www.zeromq.org/docs:2-1-upgrade</a> while the following is the part that concerns me most:</p>
  
  <pre><code>In 2.0, ZeroMQ would ignore any interrupted system calls, which meant that no ZeroMQ
  call would ever return EINTR if a signal was received during its operation. This caused
  problems with loss of signals such as SIGINT (Ctrl-C handling), especially for language
  runtimes. In 2.1, any blocking ZeroMQ call such as zmq_recv[3] will return EINTR if it
  is interrupted by a signal.
  </code></pre>
  
  <p>So does anybody knows how to wrap my blocking calls to handle <code>EINTR</code>?</p>