Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for corrupted tasklist command #946

Merged
merged 1 commit into from
Mar 5, 2019

Conversation

snjeza
Copy link
Contributor

@snjeza snjeza commented Mar 1, 2019

Fixes redhat-developer/vscode-java#815

Signed-off-by: Snjezana Peco snjezana.peco@redhat.com

@snjeza snjeza requested review from gorkem and fbricon March 1, 2019 21:34
@@ -77,6 +77,11 @@ private boolean parentProcessStillRunning() {
process.destroy();
finished = process.waitFor(POLL_DELAY_SECS, TimeUnit.SECONDS); // wait for the process to stop
}
if (Platform.OS_WIN32.equals(Platform.getOS()) && finished && process.exitValue() > 1) {
// the tasklist command should return 0 (parent process exists) or 1 (parent process doesn't exist)
JavaLanguageServerPlugin.logInfo("The tasklist command: '" + command + "' returns " + process.exitValue());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last time I tried logging anything in that method, it would "activate" the server, making it wait another 30sec before the next polling

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can test using the following patch:

diff --git a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/ParentProcessWatcher.java b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/ParentProcessWatcher.java
index 597d24e6..6ab798c7 100644
--- a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/ParentProcessWatcher.java
+++ b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/ParentProcessWatcher.java
@@ -64,7 +64,7 @@ public final class ParentProcessWatcher implements Runnable, Function<MessageCon
                }
                String command;
                if (Platform.OS_WIN32.equals(Platform.getOS())) {
-                       command = "cmd /c \"tasklist /FI \"PID eq " + pid + "\" | findstr " + pid + "\"";
+                       command = "cmd /c \"tasklist2 /FI \"PID eq " + pid + "\" | findstr " + pid + "\"";
                } else {
                        command = "ps -p " + pid;
                }

@fbricon
Copy link
Contributor

fbricon commented Mar 5, 2019

L47, add :

LOGGER.warning("Parent process stopped running, forcing server exit");
			

Signed-off-by: Snjezana Peco <snjezana.peco@redhat.com>
@snjeza
Copy link
Contributor Author

snjeza commented Mar 5, 2019

@fbricon I have updated the PR.

@fbricon fbricon added this to the Mid March 2019 milestone Mar 5, 2019
@fbricon fbricon merged commit ec52798 into eclipse-jdtls:master Mar 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants