jdk/test/com/sun/tools/attach/RunnerUtil.java
changeset 25155 8b98011eac74
parent 24268 43fb1c9e594c
child 25182 1f6766bac82c
equal deleted inserted replaced
25154:a4252397d312 25155:8b98011eac74
   137         System.out.println("Reading port and pid from file: " + filename);
   137         System.out.println("Reading port and pid from file: " + filename);
   138         File file = new File(filename);
   138         File file = new File(filename);
   139         String content = null;
   139         String content = null;
   140 
   140 
   141         // Read file or wait for it to be created.
   141         // Read file or wait for it to be created.
       
   142         long startTime = System.currentTimeMillis();
       
   143         long lastWarningTime = 0;
   142         while (true) {
   144         while (true) {
   143             content = readFile(file);
   145             content = readFile(file);
   144             if (content != null && content.indexOf("done") >= 0) {
   146             if (content != null && content.indexOf("done") >= 0) {
   145                 break;
   147                 break;
   146             }
   148             }
   147             Thread.sleep(100);
   149             Thread.sleep(100);
       
   150             long elapsedTime = (System.currentTimeMillis() - startTime) / 1000;
       
   151             if (elapsedTime > lastWarningTime) {
       
   152                 lastWarningTime = elapsedTime;
       
   153                 System.out.println("Waited " + elapsedTime + " seconds for file.");
       
   154             }
   148         }
   155         }
   149 
   156 
   150         ProcessInfo info = new ProcessInfo();
   157         ProcessInfo info = new ProcessInfo();
   151         // search for a line with format: key=nnn
   158         // search for a line with format: key=nnn
   152         Pattern pattern = Pattern.compile("(\\w*)=([0-9]+)\\r?\\n");
   159         Pattern pattern = Pattern.compile("(\\w*)=([0-9]+)\\r?\\n");