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

(process) Process.waitFor does not wait or kills process

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • P4
    • None
    • 1.2.1, 1.3.0
    • core-libs
    • generic, x86, sparc
    • generic, solaris_2.6, windows_nt

    Description


      As part of Java Web Start, we can download and install JREs
      automatically. This means executing the shell scripts that
      install the Solaris version of the JRE.

      The code for doing this runs perfectly fine on JRE 1.2.2, and
      the JRE 1.3.0 reference implementation - but FAILS on the
      latest JRE 1.3.0 production built.
      (taken from /usr/local/java/jdk1.3/solaris/bin).

      The install scripts gets executed allright. The inputstreams
      and outputsteams of the process gets redirected. We wait
      for the [yes or no] string in the licensing aggreeement, and
      then pipe out 'yes'. After that the input and output streams
      gets closed to get the process to continue, and we call 'waitFor'.

      On JRE 1.2.2 and 1.3.0-Reference this works perfectly.

      On JRE 1.3.0 Product - The executing process dies at
      or right before the waitFor call.

      This is either a bug or a change in semantics from the 1.3.0/1.2.2
      reference releases. It is mostly likely related to the redirection
      logic

      The JRE installation is a critical component for Java Web Start.

      The code for doing the execution is shown below:

          public static boolean execute(String execString) {
              Config.trace("Executing: " + execString);
              
              Process p;
              try {
                  p = Runtime.getRuntime().exec(execString);
              }
              catch (IOException ioe) {
                  return false;
              }
              
              InputStream processIS = p.getInputStream();
              OutputStream processOS = p.getOutputStream();
              int counter = 0;
              String waitString;
              boolean failed = false;
              try {
                  while ((waitString = Config.getWaitString(counter)) != null) {
                      String responseString = Config.getResponseString(counter);
                      Config.trace("Waiting for: " + waitString +
                                       " response: " + responseString);
                      if (waitFor(waitString, processIS)) {
                          if (responseString != null) {
                              processOS.write(responseString.getBytes());
                          }
                      }
                      counter++;
                  }
                  
                  // cleanup
                  try {
                      processOS.close();
                  }
                  catch (IOException ioe) {}
                  
                  // Wait for the process to finish
                  Config.trace("Wating for process to finish");
                  try {
                      p.waitFor();
                  } catch (InterruptedException ie) {
                      Config.trace("Got interrupt exception: " + ie);
                      return false;
                  }
                  Config.trace("Process ended");
                  
                  try {
                      processIS.close();
                  }
                  catch (IOException ioe) {}
                  
                  return true;
              } catch (IOException ioe) {
                  Config.trace("Got IO exception: " + ioe);
                  return false;
                }
          }
        
      To reproduce:

       - Needs latest Java Web Start release from engineering (me).
         (or wait for next promotion on 9/11)

       - Install Java Web Start

       - Configure Java Web Start to only have JRE 1.3.0 production installed

       - Click on the Formula 1 link on http://ignoramus/jump/index2.html

      Once this is done. The installer can be invoked from the command line
      using a script like this:

       #!/bin/ksh
       set -x
       app=/home/renes/.javaws/cache/V1.2.2/http/Dignoramus.eng/P80/DMjnlp/DMservlet/EMExtensionInstallerServer
       java -DtrustProxy=true -Djava.security.policy=javaws.policy -Djnlpx.remove=false -Djnlpx.home=/home/renes/local/ws/jaws/build/solaris/bin -Djnlpx.jvm=/usr/local/java/jdk1.3/solaris/bin/java -classpath javaws.jar:jaxp.jar com.sun.javaws.Main $app

      It is probably easiest to get me to help with this setup.


      As part of Java Web Start, we do automatic installation of
      JREs. This means downloading and executing the JRE installation
      shell

      (This was running on a Ulta 10 on Solaris 2.8)

      Attachments

        Activity

          People

            iris Iris Clark
            rschmidtsunw Rene Schmidt (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: