8239893: Windows handle Leak when starting processes using ProcessBuilder

Reviewed-by: bpb, naoto
This commit is contained in:
Roger Riggs 2020-03-06 13:52:35 -05:00
parent e2f4319171
commit 375d0c1325
3 changed files with 153 additions and 1 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -496,6 +496,7 @@ final class ProcessImpl extends Process {
else {
FileDescriptor stdin_fd = new FileDescriptor();
fdAccess.setHandle(stdin_fd, stdHandles[0]);
fdAccess.registerCleanup(stdin_fd);
stdin_stream = new BufferedOutputStream(
new FileOutputStream(stdin_fd));
}
@ -505,6 +506,7 @@ final class ProcessImpl extends Process {
else {
FileDescriptor stdout_fd = new FileDescriptor();
fdAccess.setHandle(stdout_fd, stdHandles[1]);
fdAccess.registerCleanup(stdout_fd);
stdout_stream = new BufferedInputStream(
new PipeInputStream(stdout_fd));
}
@ -514,6 +516,7 @@ final class ProcessImpl extends Process {
else {
FileDescriptor stderr_fd = new FileDescriptor();
fdAccess.setHandle(stderr_fd, stdHandles[2]);
fdAccess.registerCleanup(stderr_fd);
stderr_stream = new PipeInputStream(stderr_fd);
}