title: Node.js process.exit() will not exit with a createReadStream open
body: <p>I have a program that communicates with Asterisk via EAGI. Asterisk opens up my Node.js application and sends it data via STDIN and the program sends Asterisk commands via STDOUT. When a user hangs up, the Node.js process gets sent a SIGHUP command. This is intercepted for cleaner exiting. This functionality is working.</p>
  
  <p>Asterisk also sends RAW audio data on fd 3 (STDERR+1). The Node.js process intercepts the data properly, and is able to read the audio, convert it, or anything else that needs to be done. However, when the createReadStream is created on fd 3, the Node.js process will NOT exit and quickly becomes a Zombie. If I comment out the createReadStream code, Node.js exits as expected.</p>
  
  <p>How can I get Node.js to exit with the process.exit() function like it's supposed to? I'm using Node.js version v0.10.30.</p>
  
  <p>Node.js createReadStream code:</p>
  
  <pre><code>// It was success
  this.audioInStream = fs.createReadStream( null, { 'fd' : 3 } );
  
  // Pipe the audio stream to a blackhole for now so it doesn't get queued up
  this.audioInStream.pipe( blackhole() );
  </code></pre>
  
  <p>SIGHUP code:</p>
  
  <pre><code>process
  .on( 'SIGHUP', function() {
      log.message.info( "[%s] Asterisk process hung up.", that.callerid );
      that.exitWhenReady();
  } );
  </code></pre>
  
  <p>exitWhenReady function</p>
  
  <pre><code>Index.prototype.exitWhenReady = function() {
      if( !this.canExit )
          return;
  
      log.message.info( "[%s] Exiting program successfully.", this.callerid );
  
      // Get rid of our streams
      this.audioInStream.unpipe();
      this.audioInStream.close();
      this.audioInStream.destroy();
  
      process.exit( 0 );
  };
  </code></pre>
  
  <p>Blackhole module:</p>
  
  <pre><code>var inherits = require( 'util' ).inherits;
  var Writable = require( 'stream' ).Writable;
  var process = require( 'process' );
  
  function Blackhole( opts ) {
      if( !(this instanceof Blackhole) )
          return( new Blackhole( opts ) );
  
      if( !opts )
          opts = {};
  
      Writable.call( this, opts );
  }
  
  inherits( Blackhole, Writable );
  
  Blackhole.prototype._write = function( chunk, encoding, done ) {
      process.nextTick( done );
  };
  
  module.exports = Blackhole;
  </code></pre>
  
  <p>It is notable that</p>
  
  <blockquote>
    <p>Asterisk process hung up</p>
  </blockquote>
  
  <p>And</p>
  
  <blockquote>
    <p>Exiting program successfully.</p>
  </blockquote>
  
  <p>Never show up in log file when createReadStream is reading fd 3, but when it isn't they do.</p>