Skip to content

Commit f8f3485

Browse files
Increase polling frequency to ensure that Java processes are detected (microsoft#416)
* Increase polling frequency to ensure that Java processes are detected
1 parent 4dacc16 commit f8f3485

File tree

1 file changed

+9
-2
lines changed
  • com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler

1 file changed

+9
-2
lines changed

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/LaunchUtils.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public static ProcessHandle findJavaProcessInTerminalShell(long shellPid, String
117117
ProcessHandle shellProcess = ProcessHandle.of(shellPid).orElse(null);
118118
if (shellProcess != null) {
119119
int retry = 0;
120-
final int INTERVAL = 100;
120+
final int INTERVAL = 20/*ms*/;
121121
final int maxRetries = timeout / INTERVAL;
122122
final boolean isCygwinShell = isCygwinShell(shellProcess.info().command().orElse(null));
123123
while (retry <= maxRetries) {
@@ -127,11 +127,17 @@ public static ProcessHandle findJavaProcessInTerminalShell(long shellPid, String
127127
}).findFirst();
128128

129129
if (subProcessHandle.isPresent()) {
130+
if (retry > 0) {
131+
logger.info("Retried " + retry + " times to find Java subProcess.");
132+
}
130133
logger.info("shellPid: " + shellPid + ", javaPid: " + subProcessHandle.get().pid());
131134
return subProcessHandle.get();
132135
} else if (isCygwinShell) {
133136
long javaPid = findJavaProcessByCygwinPsCommand(shellProcess, javaCommand);
134137
if (javaPid > 0) {
138+
if (retry > 0) {
139+
logger.info("Retried " + retry + " times to find Java subProcess.");
140+
}
135141
logger.info("[Cygwin Shell] shellPid: " + shellPid + ", javaPid: " + javaPid);
136142
return ProcessHandle.of(javaPid).orElse(null);
137143
}
@@ -147,8 +153,9 @@ public static ProcessHandle findJavaProcessInTerminalShell(long shellPid, String
147153
} catch (InterruptedException e) {
148154
// do nothing
149155
}
150-
logger.info("Retry to find Java subProcess of shell pid " + shellPid);
151156
}
157+
158+
logger.info("Retried " + retry + " times but failed to find Java subProcess of shell pid " + shellPid);
152159
}
153160

154161
return null;

0 commit comments

Comments
 (0)