diff --git a/terminal/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/local/showin/detectors/DetectWSL.java b/terminal/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/local/showin/detectors/DetectWSL.java index 0f1300b1c95..8d98d53f786 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/local/showin/detectors/DetectWSL.java +++ b/terminal/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/local/showin/detectors/DetectWSL.java @@ -144,6 +144,18 @@ public class DetectWSL implements IDetectExternalExecutable { } } + try { + // lets get the return code to make sure that the process did not produce anything unexpected. As the streams + // are closed, the waitFor shouldn't block. + if (process.waitFor() != 0) { + // WSL can send errors to stdout, so discard results if the exit value ends up being non-zero + result.clear(); + } + } catch (InterruptedException e) { + // we've been interrupted, give up on the output we have (probably unreachable in practice) + result.clear(); + } + } catch (IOException e) { } }