Skip to content

Commit

Permalink
Increase polling frequency to ensure that Java processes are detected (
Browse files Browse the repository at this point in the history
…#416)

* Increase polling frequency to ensure that Java processes are detected
  • Loading branch information
testforstephen committed May 31, 2022
1 parent 4dacc16 commit f8f3485
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public static ProcessHandle findJavaProcessInTerminalShell(long shellPid, String
ProcessHandle shellProcess = ProcessHandle.of(shellPid).orElse(null);
if (shellProcess != null) {
int retry = 0;
final int INTERVAL = 100;
final int INTERVAL = 20/*ms*/;
final int maxRetries = timeout / INTERVAL;
final boolean isCygwinShell = isCygwinShell(shellProcess.info().command().orElse(null));
while (retry <= maxRetries) {
Expand All @@ -127,11 +127,17 @@ public static ProcessHandle findJavaProcessInTerminalShell(long shellPid, String
}).findFirst();

if (subProcessHandle.isPresent()) {
if (retry > 0) {
logger.info("Retried " + retry + " times to find Java subProcess.");
}
logger.info("shellPid: " + shellPid + ", javaPid: " + subProcessHandle.get().pid());
return subProcessHandle.get();
} else if (isCygwinShell) {
long javaPid = findJavaProcessByCygwinPsCommand(shellProcess, javaCommand);
if (javaPid > 0) {
if (retry > 0) {
logger.info("Retried " + retry + " times to find Java subProcess.");
}
logger.info("[Cygwin Shell] shellPid: " + shellPid + ", javaPid: " + javaPid);
return ProcessHandle.of(javaPid).orElse(null);
}
Expand All @@ -147,8 +153,9 @@ public static ProcessHandle findJavaProcessInTerminalShell(long shellPid, String
} catch (InterruptedException e) {
// do nothing
}
logger.info("Retry to find Java subProcess of shell pid " + shellPid);
}

logger.info("Retried " + retry + " times but failed to find Java subProcess of shell pid " + shellPid);
}

return null;
Expand Down

0 comments on commit f8f3485

Please sign in to comment.