diff --git a/java/src/org/openqa/selenium/os/ExternalProcess.java b/java/src/org/openqa/selenium/os/ExternalProcess.java index 2b7d933a9b76e..95dfffe9e67b5 100644 --- a/java/src/org/openqa/selenium/os/ExternalProcess.java +++ b/java/src/org/openqa/selenium/os/ExternalProcess.java @@ -198,10 +198,13 @@ public ExternalProcess start() throws UncheckedIOException { new Thread( () -> { + // copyOutputTo might be system.out or system.err, do not to close + OutputStream output = new MultiOutputStream(circular, copyOutputTo); + // closing the InputStream does somehow disturb the process, do not to close + InputStream input = process.getInputStream(); // use the CircularOutputStream as mandatory, we know it will never raise a // IOException - try (InputStream input = process.getInputStream(); - OutputStream output = new MultiOutputStream(circular, copyOutputTo)) { + try { // we must read the output to ensure the process will not lock up input.transferTo(output); } catch (IOException ex) {