View | Details | Raw Unified | Return to bug 56810
Collapse All | Expand All

(-)TesterOpenSSL.java (-1 / +19 lines)
Lines 180-186 Link Here
180
        t2.start();
180
        t2.start();
181
181
182
        try {
182
        try {
183
            p.waitFor(2, TimeUnit.SECONDS);
183
            waitForProcess(p, 2);
184
        } catch (InterruptedException e) {
184
        } catch (InterruptedException e) {
185
            throw new IOException(e);
185
            throw new IOException(e);
186
        }
186
        }
Lines 193-198 Link Here
193
        return stdout.getText().trim();
193
        return stdout.getText().trim();
194
    }
194
    }
195
195
196
    private static boolean waitForProcess(Process p, int seconds) throws InterruptedException {
197
        long startTime = System.nanoTime();
198
        long rem = TimeUnit.SECONDS.toNanos(seconds);
199
200
        do {
201
            try {
202
                p.exitValue();
203
                return true;
204
            } catch(IllegalThreadStateException ex) {
205
                if (rem > 0) {
206
                    Thread.sleep(Math.min(TimeUnit.NANOSECONDS.toMillis(rem) + 1, 100));
207
                }
208
            }
209
            rem = TimeUnit.SECONDS.toNanos(seconds) - (System.nanoTime() - startTime);
210
        } while (rem > 0);
211
        return false;
212
    }
213
    
196
    private static class InputStreamToText implements Runnable {
214
    private static class InputStreamToText implements Runnable {
197
215
198
        private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
216
        private final ByteArrayOutputStream baos = new ByteArrayOutputStream();

Return to bug 56810