exit from waitFor() after the specified pattern occurs for the second time
diff --git a/rse/plugins/org.eclipse.dltk.rse.core/src/org/eclipse/dltk/core/internal/rse/MyHostShellProcessAdapter.java b/rse/plugins/org.eclipse.dltk.rse.core/src/org/eclipse/dltk/core/internal/rse/MyHostShellProcessAdapter.java
index 3d768d0..6bfa132 100644
--- a/rse/plugins/org.eclipse.dltk.rse.core/src/org/eclipse/dltk/core/internal/rse/MyHostShellProcessAdapter.java
+++ b/rse/plugins/org.eclipse.dltk.rse.core/src/org/eclipse/dltk/core/internal/rse/MyHostShellProcessAdapter.java
@@ -45,6 +45,7 @@
private PipedOutputStream hostShellInput = null;
private PipedOutputStream hostShellError = null;
private String pattern1;
+ private boolean done = false;
/**
* Constructor.
@@ -93,7 +94,7 @@
* always returns 0.
*/
public synchronized int exitValue() {
- if (hostShell.isActive())
+ if (!done && hostShell.isActive())
throw new IllegalThreadStateException();
// No way to tell what the exit value was.
// TODO it would be possible to get the exit value
@@ -138,7 +139,7 @@
*/
public synchronized int waitFor() throws InterruptedException {
- while (hostShell.isActive()) {
+ while (!done && hostShell.isActive()) {
try {
wait(1000);
} catch (InterruptedException e) {
@@ -165,6 +166,11 @@
return 0;
}
+ private synchronized void endOfOutput() {
+ done = true;
+ notifyAll();
+ }
+
/**
* Process an RSE Shell event, by writing the lines of text contained in the
* event into the adapter's streams.
@@ -198,9 +204,7 @@
}
prefixCounter++;
if (prefixCounter == 2) {
- // System.out.println("CALL DESTROY");
- hostShellError.close();
- hostShellInput.close();
+ endOfOutput();
return;
}
continue;