8337300: java/lang/Process/WaitForDuration.java leaves child process behind

Reviewed-by: alanb, iris, bpb
This commit is contained in:
Naoto Sato 2024-07-29 16:43:25 +00:00
parent ee365d75cc
commit c23d37e10a

View File

@ -55,9 +55,14 @@ public class WaitForDuration {
@MethodSource("durations")
void testEdgeDurations(Duration d, int sleepMillis, boolean expected)
throws IOException, InterruptedException {
var pb = ProcessTools.createTestJavaProcessBuilder(
WaitForDuration.class.getSimpleName(), Integer.toString(sleepMillis));
assertEquals(expected, pb.start().waitFor(d));
var child = ProcessTools.createTestJavaProcessBuilder(
WaitForDuration.class.getSimpleName(), Integer.toString(sleepMillis))
.start();
try {
assertEquals(expected, child.waitFor(d));
} finally {
child.destroy();
}
}
@Test