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

(process) JVM 1.2 hangs when executing external

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 1.2.0
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_95

      Description



      Name: dbT83986 Date: 03/03/99


      // Compile and run the Java class below. The JVM will hang. It works fine under JDK 1.1.7

      // Source code (please note this is an example -with minor modifications to adapt it to Windows- taken from the book "Java
      // Class Libraries Second Edition, Volume 1; page 1365):

      import java.io.*;

      public class ls
      {
          public static void main(String[] args)
          {
              try
              {
                  String cmd = "ls.bat";
                  Process child = Runtime.getRuntime().exec(cmd);
                  InputStream in = child.getInputStream();
                  int c, newline = 0, maxlines = 10;
                  if (args.length > 0)
                      maxlines = Integer.parseInt(args[0]);
                  while ((c = in.read()) != -1 && newline < maxlines)
                  {
                      char ch = (char)c;
                      System.out.print(ch);
                      if (ch == '\n')
                          ++newline;
                  }
                  in.close();
                  child.destroy();
              }
              catch (IOException ioe)
              {
                  System.err.println(ioe);
              }
          }
      }
      (Review ID: 52231)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              hongzh Hong Zhang
              Reporter:
              dblairsunw Dave Blair (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: