title: Windows process exec'ed from Java not terminating
body: <p>I'm creating a process on Windows from Java. My problem is that this process doesn't terminate. Here's a sample program:</p>
  
  <pre><code>import java.io.IOException;
  
  public class Test {
  
  /**
   * @param args
   * @throws IOException
   * @throws InterruptedException
   */
  public static void main(String[] args) throws IOException,
          InterruptedException {
      Process process = Runtime.getRuntime().exec("cmd /c dir");
      process.waitFor();
      }
  }
  </code></pre>
  
  <p>For reasons beyond my understanding, this program never completes. This is true if "cmd /c dir" is replaced with ipconfig as well as other things.</p>
  
  <p>I can see using ProcessExplorer that java creates the cmd process. This sample is obviously a simplification; in my original program I found that if I call process.destroy() after a while and check the cmd process output, the command is executed successfully. </p>
  
  <p>I've tried this with various releases of Java 1.5 and 1.6. My OS is Windows XP Pro, SP 2.</p>