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

(process) JVM 1.2 hangs when executing external

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.0
    • core-libs
    • x86
    • windows_95



      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)
      ======================================================================

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: