title: Reading streams from java Runtime.exec
body: <p>I have the following snippet of code:</p>
  
  <pre><code>Process proc = runtime.exec(command);
  errorGobbler = new ErrorStreamGobbler(proc.getErrorStream(), logErrors, mdcMap);
  outputGobbler = new OutputStreamGobbler(proc.getInputStream(), mdcMap);
  executor.execute(errorGobbler);
  executor.execute(outputGobbler);
  processExitCode = proc.waitFor();
  </code></pre>
  
  <p>where the gobblers are <code>Runnable</code>s which use a <code>BufferedReader</code> to read the input and error streams of the executing process. While this works most of the time, I get the occasional window (of about 2 minutes or so) where I get the <code>processExitCode</code> as 0, which indicates normal termination but there is nothing in the input and error streams - nothing to even indicate end-of-stream. </p>
  
  <p>Like I indicated before, this works most of the time but this failure occurs every once in a while - and I am totally puzzled. Any ideas?</p>
  
  <p>Rags</p>