Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7131522

Runtime.getRuntime().exec() and ProcessBuilder.start() cause parent JVM to exit

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • 7
    • core-libs
    • 7u1
    • x86
    • windows_7

      FULL PRODUCT VERSION :
      java version "1.7.0_02"
      Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Windows 7 Enterprise Edition, 64-bit

      A DESCRIPTION OF THE PROBLEM :
      Runtime.getRuntime().exec() and ProcessBuilder.start() causes the calling JVM to exit silently. The child process is never spawned.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      First off - the problem occurs in version 1.7.0_01. The version mentioned above is the version that the problem disappears in the following code:

      System.err.println("##### creating ProcessBuilder ...");
      ProcessBuilder pb = new ProcessBuilder();

      System.err.println("##### setting command line args ...");
      pb.command("java","-jar","some-executable-jar.jar");

      System.err.print("##### starting ProcessBuilder: ");
      for(String opt : pb.command()) System.err.print(opt+" ");
      System.err.println();

      pb.start();
      System.err.println("##### Process started, exiting host process ...");
      System.exit(0);

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The child process is supposed to display a new JFrame, so I would expect that to happen shortly after seeing the last "...exiting host process ..." print statement to appear on the host process' console.
      ACTUAL -
      I see all by the final print statement get printed to the console, then the parent JVM dies. As far as I can tell, the child process never gets started.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      There is no error message.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      System.err.println("##### creating ProcessBuilder ...");
      ProcessBuilder pb = new ProcessBuilder();

      System.err.println("##### setting command line args ...");
      pb.command("java","-jar","some-executable-jar.jar");

      System.err.print("##### starting ProcessBuilder: ");
      for(String opt : pb.command()) System.err.print(opt+" ");
      System.err.println();

      pb.start();
      System.err.println("##### Process started, exiting host process ...");
      System.exit(0);
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Updating to Java 1.7.0_02 seems to have fixed the problem.

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: