[Bug libgcj/30937] Win32: Process.exitValue() does not work after multiple calls to a terminated process

r_ovidius at eml dot cc gcc-bugzilla@gcc.gnu.org
Fri Feb 23 20:53:00 GMT 2007



------- Comment #1 from r_ovidius at eml dot cc  2007-02-23 20:53 -------
Also seems to affect process.destroy() somehow.  The "DONE" is not printed
after the destroy call on gcj win32, but is on Sun.




public class ProcTest {

  static Process process;

  public static void main(String[] args) {
    try {
      String bat = "exitcode.bat";
      PrintStream p = new PrintStream(new FileOutputStream(bat));
      p.println("@exit 5");
      p.close();

      process = Runtime.getRuntime().exec(bat);

      try {
        int wf = process.waitFor();
        System.err.println(wf);
      } catch (InterruptedException e) {
      }

      try {
        int ev = process.exitValue();
        System.err.println("EV: " + ev + " " + process);
      } catch (IllegalThreadStateException ile) {
        System.err.println("X: " + ile);
      }

      try {
        int ev = process.exitValue();
        System.err.println("EV: " + ev + " " + process);
      } catch (IllegalThreadStateException ile) {
        System.err.println("X: " + ile);
      }

      process.destroy();

      System.err.println("DONE");

    } catch (Exception e) {
      e.printStackTrace();
    }

  }

}


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30937



More information about the Java-prs mailing list