title: Node.js catch ENOMEM error thrown after spawn
body: <p>My Node.js script crashes because of a thrown ENOMEM (Out of memory) errnoException when using <a href="http://nodejs.org/api/child_process.html" rel="noreferrer">spawn</a>.</p>
  <p>The error:</p>
  <pre><code>child_process.js:935
    throw errnoException(process._errno, 'spawn');
          ^
  
  Error: spawn ENOMEM
    at errnoException (child_process.js:988:11)
    at ChildProcess.spawn (child_process.js:935:11)
    at Object.exports.spawn (child_process.js:723:9)
    at module.exports ([...]/node_modules/zbarimg/index.js:19:23)
  </code></pre>
  <p>I'm already using listeners for the <code>error</code> and <code>exit</code> event, but non of them getting fired in case of this error.</p>
  <p>My code:</p>
  <pre><code>zbarimg = process.spawn('zbarimg', [photo, '-q']);
  zbarimg.on('error', function(err) { ... });
  zbarimg.on('close', function(code) { ... }); 
  </code></pre>
  <p>Full source code <a href="https://github.com/electerious/zbarimg" rel="noreferrer">available</a>.</p>
  <p>Is there anything I can do to prevent the script from crashing? How do I catch the thrown ENOMEM error?</p>