Skip to content

Commit e494661

Browse files
committed
[java] prevent closing the stdin, stdout, stderr streams #14569
1 parent 66dbd3c commit e494661

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

java/src/org/openqa/selenium/os/ExternalProcess.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,11 @@ public void shutdown() {
317317
*/
318318
public void shutdown(Duration timeout) {
319319
try {
320-
if (process.supportsNormalTermination()) {
321-
process.destroy();
320+
// use the handle to prevent closing the stdin, stdout, stderr streams
321+
ProcessHandle handle = process.toHandle();
322+
323+
if (handle.supportsNormalTermination()) {
324+
handle.destroy();
322325

323326
try {
324327
if (process.waitFor(timeout.toMillis(), MILLISECONDS)) {
@@ -330,7 +333,7 @@ public void shutdown(Duration timeout) {
330333
}
331334
}
332335

333-
process.destroyForcibly();
336+
handle.destroyForcibly();
334337
try {
335338
process.waitFor(timeout.toMillis(), MILLISECONDS);
336339
} catch (InterruptedException ex) {

0 commit comments

Comments
 (0)