*/
package com.intellij.execution.process;
+import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Key;
import java.nio.charset.Charset;
* @author yole
*/
public class CapturingProcessHandler extends OSProcessHandler {
+ private static final Logger LOG = Logger.getInstance(CapturingProcessHandler.class);
private final Charset myCharset;
private final ProcessOutput myOutput = new ProcessOutput();
public ProcessOutput runProcess() {
startNotify();
- waitFor();
- myOutput.setExitCode(getProcess().exitValue());
+ if (waitFor()) {
+ myOutput.setExitCode(getProcess().exitValue());
+ } else {
+ LOG.info("runProcess: exit value unavailable");
+ }
return myOutput;
}
public abstract boolean detachIsDefault();
- public void waitFor() {
+ /**
+ * Wait for process execution.
+ * @return true if target process has actually ended; false if we stopped watching the process execution and don't know if it has completed.
+ */
+ public boolean waitFor() {
try {
myWaitSemaphore.waitFor();
+ return true;
}
catch (ProcessCanceledException e) {
- // Ignore
+ return false;
}
}