title: Node.js - Error: write EPIPE code: 'EPIPE
body: <p>I keep getting EPIPE error, on stdin stream and I can't find a reason:</p>
  
  <p>This is my code:</p>
  
  <pre><code>var checkFile = function(data, callback){
     var child_process = spawn('ffprobe', ['-print_format', 'json', '-show_format', 'pipe:0']);
  
     var stdInError = function(e) {
         console.log(e);
     }
     child_process.stdin.on('error', stdInError);
  
     var generalError = function() {
         console.log("general Error" + "\n");
     }
     child_process.on('error', generalError);
  
     child_process.stdout.on('data', function(data){
          console.log("data" + "\n");
          console.log(data);
          console.log("\n");
     });
  
     child_process.on('close', function(){
         console.log("close" + "\n");
     }
  
     var exit = function(){
         console.log("exit");
     }
     child_process.on('exit', exit);
  
     console.log("write" + "\n");
     child_process.stdin.write(data);
     child_process.stdin.end();
  };
  </code></pre>
  
  <p>And this is my output:</p>
  
  <pre><code>write
  
  data
  
  &lt;Buffer 7b 0a 20 20 20 20 22 66 6f 72 6d 61 74 22 3a 20 7b 0a 20 20 20 20 20 20 20 20 22 66 69 6c 65 6e 61 6d 65 22 3a 20 22 70 69 70 65 3a 30 22 2c 0a 20 20 20 ...&gt;
  
  data
  
  &lt;Buffer 0a 7d 0a&gt;
  
  { [Error: write EPIPE] code: 'EPIPE', errno: 'EPIPE', syscall: 'write' }
  
  exit
  close
  </code></pre>
  
  <p>I cannot find a reason for this error, i have also tried to implement</p>
  
  <pre><code>child_process.stderr.on('data', function (data) {
      //throw errors
      console.log('stderr: ' + data);
  });
  </code></pre>
  
  <p>And every line printed from ffprobe (which is a software to check audio/video files specs) is marked as stderr. For example: </p>
  
  <p>stderr: ffprobe version 2.2.4 Copyright (c) 2007-2014 the FFmpeg developers
  built on Jul  2 2014 15:07:45 with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
    configuration: --prefix=/usr/local/Cellar/ffmpeg/2.2.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid --enable-libfreetype --enable-libtheora --enable-libvorbis --enable-libvpx --enable-librtmp --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-aacenc --enable-libass --enable-ffplay --enable-libspeex --enable-libschroedinger --enable-libfdk-aac --enable-libopus --enable-frei0r --enable-libopenjpeg --extra-cflags='-I/usr/local/Cellar/openjpeg/1.5.1_1/include/openjpeg-1.5 '
    libavutil      52. 66.100 / 52. 66.100</p>
  
  <p>stderr:   libavcodec     55. 52.102 / 55. 52.102
    libavformat    55. 33.100 / 55. 33.100
    libavdevice    55. 10.100 / 55. 10.100
    libavfilter     4.  2.100 /  4.  2.100
    libavresample   1.  2.  0 /  1.  2.  0
    libswscale      2.  5.102 /  2.  5.102
    libswresample   0. 18.100 /  0. 18.100
    libpostproc    52.  3.100 / 52.  3.100</p>