From 489658dbd2cd518a17611dcc01c0109046cf97a8 Mon Sep 17 00:00:00 2001 From: Chris Plummer Date: Thu, 11 May 2023 17:07:27 +0000 Subject: [PATCH] 8307885: com/sun/jdi/ConnectedVMs.java fails with "Invalid debuggee exitValue: 0" Reviewed-by: kevinw, sspitsyn --- test/jdk/com/sun/jdi/ConnectedVMs.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/jdk/com/sun/jdi/ConnectedVMs.java b/test/jdk/com/sun/jdi/ConnectedVMs.java index 0b3ac6a1e71..7e3468392c6 100644 --- a/test/jdk/com/sun/jdi/ConnectedVMs.java +++ b/test/jdk/com/sun/jdi/ConnectedVMs.java @@ -69,15 +69,19 @@ public class ConnectedVMs extends TestScaffold { protected boolean allowedExitValue(int exitValue) { if (passName.equals("Kill")) { // 143 is SIGTERM, which we expect to get when doing a Process.destroy(), - // unless we are on Windows, which will exit with a 1. + // unless we are on Windows, which will exit with a 1. However, sometimes + // there is a race and the main thread exits before SIGTERM can force + // an exit(143), so we need to allow exitValue 0 also. if (!Platform.isWindows()) { - return exitValue == 143; + return exitValue == 143 || exitValue == 0; } else { - return exitValue == 1; + return exitValue == 1 || exitValue == 0; } } else if (passName.equals("exit()")) { // This version of the test does an exit(1), so that's what we expect. - return exitValue == 1; + // But similar to the SIGTERM race issue, the exit(1) might not happen + // before the main thread exits, so we need to expect 0 also. + return exitValue == 1 || exitValue == 0; } return super.allowedExitValue(exitValue); }