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:
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())
The exit value is : 1.
Javadoc says: by convention, the value 0 indicates normal termination. http://download.oracle.com/javase/6/docs/api/java/lang/Process.html#exitValue()
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'.
My question is:
- Why program returns exit code as '1' in first case? Does JVM treats p1.destroy() as abnormal way of terminating a program?
- 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..
Thank you for reading,
Process.destroywhich probably uses the Win32TerminateProcess) is not something I'd consider "normal" termination...