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

(process) Wrong exit code may be returned if process ends too quickly (lnx)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.1
    • core-libs



      Name: nt126004 Date: 08/13/2002


      FULL PRODUCT VERSION :
      java version "1.4.1-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b14)
      Java HotSpot(TM) Client VM (build 1.4.1-beta-b14, mixed mode)

      FULL OPERATING SYSTEM VERSION :
      glibc: glibc-2.2.5-34
      kernel: Linux NetworkTester2 2.4.18-3 #1 Thu Apr 18
      07:37:53 EDT 2002 i686 unknown
      distribution: Red Hat Linux release 7.3 (Valhalla)


      A DESCRIPTION OF THE PROBLEM :
      When you launch a process to execute a (bash) shell script
      on Linux, if the script uses the "exit" command to return
      its exit status, that status is not returned by
      Process.waitFor() correctly (as it does w/ previous
      JREs). Appears to be returning 0 almost always.

      REGRESSION. Last worked in version 1.4

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Place Test.class and test.sh in same directory.
      2. Execute the Test class
      3. See the results

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Expected (sample):

      % uname -sr
      Linux 2.4.18-3
      % cat test.sh
      #!/bin/bash
      #
      exit 2
      % java -showversion Test
      java version "1.4.1-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build
      1.4.1-beta-b14)
      Java HotSpot(TM) Client VM (build 1.4.1-beta-b14, mixed
      mode)

      Exit val: 2


      Actual (sample):

      % uname -sr
      Linux 2.4.18-3
      % cat test.sh
      #!/bin/bash
      #
      exit 2
      % java -showversion Test
      java version "1.4.1-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build
      1.4.1-beta-b14)
      Java HotSpot(TM) Client VM (build 1.4.1-beta-b14, mixed
      mode)

      Exit val: 0

      REPRODUCIBILITY :
      This bug can be reproduced often.

      ---------- BEGIN SOURCE ----------
      ************ start Test.java **************
      public class Test {
          public static void main(String args[]) {
              try {
                  String[] cmd= { "/bin/bash", "-c", "./test.sh" };
                  Process p = Runtime.getRuntime().exec(cmd);
                  int exitVal = p.waitFor();
                  System.out.println("Exit val: " + exitVal);
              }
              catch (Exception e ) {
                  e.printStackTrace();
              }
          }
      }
      ************ end Test.java **************


      ************ start test.sh **************
      #!/bin/bash
      #
      exit 2
      ************ end test.sh **************

      ---------- END SOURCE ----------

      Release Regression From : 1.4
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

      (Review ID: 160096)
      ======================================================================

            mr Mark Reinhold
            nthompsosunw Nathanael Thompson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: