in src/com/intellij/vssSupport/commands/VSSExecUtil.java [74:147]
private static void runProcessImpl(@NotNull final Project project, VssOutputCollector listener, GeneralCommandLine cmdLine) throws ExecutionException {
Process process = null;
VssProcess worker = null;
ProcessWaiter<VssStreamReader> waiter = null;
try {
int rc = DEFAULT_ERROR_EXIT_CODE;
try
{
process = cmdLine.createProcess();
worker = new VssProcess(process, project);
waiter = new ProcessWaiter<VssStreamReader>() {
protected VssStreamReader createStreamListener(InputStream stream) {
return new VssStreamReader(stream, project);
}
};
rc = waiter.execute(worker, TIMEOUT_LIMIT * 1000);
}
catch( java.util.concurrent.ExecutionException e ){
listener.onCommandCriticalFail( e.getMessage() );
}
catch( IOException e ) {
listener.onCommandCriticalFail( e.getMessage() );
}
catch( InterruptedException e ) {
listener.onCommandCriticalFail( e.getMessage() );
}
catch (TimeoutException e) {
rc = TIMEOUT_EXIT_CODE;
}
//-------------------------------------------------------------------------
// Process is either exits by itself with some exit code or it is aborted
// by the timeout.
// In the former case we PRE-analyze output and error streams, trying to
// find most general error messages which require for the process to be
// aborted abnormally. In the case of normal exit we notify the
// VssOutputCollector instance with the result output string.
//-------------------------------------------------------------------------
if( rc == TIMEOUT_EXIT_CODE )
{
listener.onCommandCriticalFail( VssBundle.message( "message.text.process.shutdown.on.timeout" ) );
LOG.info( "++ Command Shutdown detected ++");
} else if (waiter.getInStreamListener().getReason() != null || waiter.getErrStreamListener().getReason() != null ) {
String reason = (waiter.getInStreamListener().getReason() != null) ?
waiter.getInStreamListener().getReason() : waiter.getErrStreamListener().getReason();
LOG.info( "++ Critical error detected: " + reason );
listener.setExitCode( worker.getExitCode() );
listener.onCommandCriticalFail( reason );
listener.everythingFinishedImpl( reason );
// Hack: there is no known (so far) way to give the necessary sequence of
// characters to the input of the SS.EXE process to emulate "Enter" on its
// request to reenter the password. Thus we simply notify the parent process
// that it should finish.
worker.destroy();
}
else
{
String text = waiter.getErrStreamListener().getReadString() + waiter.getInStreamListener().getReadString();
listener.setExitCode( worker.getExitCode() );
listener.everythingFinishedImpl( text );
}
} finally {
if (worker != null) {
worker.closeProcess();
} else if ((worker == null) && (process != null)) {
InterruptibleProcess.close(process);
}
}
}