title: Process.exitValue() in Java
body: <p>Below is piece of program I was using to simply Open and close the Internet Explorer from my command line program. im running my program with Java 6 on Windows XP OS:</p>
  
  <pre><code>Runtime runtime = Runtime.getRuntime();       
  Process p1 = runtime.exec("C:\\Program Files\\Internet Explorer\\iexplore.exe");
  Thread.sleep(5000);
  p1.destroy();
  Thread.sleep(2000);
  System.out.println("p1.exitValue(): "+p1.exitValue())
  </code></pre>
  
  <p>The exit value is : 1.</p>
  
  <p>Javadoc says: by convention, the value 0 indicates normal termination.
  <a href="http://download.oracle.com/javase/6/docs/api/java/lang/Process.html#exitValue" rel="nofollow">http://download.oracle.com/javase/6/docs/api/java/lang/Process.html#exitValue</a>()</p>
  
  <p>Then I commented p1.destroy and instead of closing the browser from my Java program, I closed the window manually (File>Exit). In this case p1.exitValue started returning '0'.</p>
  
  <p>My question is:</p>
  
  <ol>
  <li>Why program returns exit code as '1' in first case? Does JVM treats p1.destroy() as abnormal way of terminating a program?  </li>
  <li>In general the 'exit status code' value is JVM specific or Operating system specific? I have seen some question where people have reported exit code value as '10', '34545' etc..</li>
  </ol>
  
  <p>Thank you for reading,</p>