Search in sources :

Example 1 with BaseDataReader

use of com.intellij.util.io.BaseDataReader in project android by JetBrains.

the class EmulatorProcessHandler method startNotify.

@Override
public void startNotify() {
    // Wait for both the stdout and stderr reader threads to finish and then indicate that the process has terminated
    addProcessListener(new ProcessAdapter() {

        @Override
        public void startNotified(final ProcessEvent event) {
            try {
                String presentableName = CommandLineUtil.extractPresentableName(myCommandLine.getCommandLineString());
                final BaseDataReader stdoutReader = new EmulatorOutputReader(myProcess.getInputStream(), ProcessOutputTypes.STDOUT, presentableName);
                final BaseDataReader stderrReader = new EmulatorOutputReader(myProcess.getErrorStream(), ProcessOutputTypes.STDERR, presentableName);
                executeTask(() -> {
                    try {
                        stderrReader.waitFor();
                        stdoutReader.waitFor();
                    } catch (InterruptedException ignore) {
                    } finally {
                        notifyProcessTerminated(0);
                    }
                });
            } finally {
                removeProcessListener(this);
            }
        }
    });
    super.startNotify();
}
Also used : ProcessAdapter(com.intellij.execution.process.ProcessAdapter) BaseDataReader(com.intellij.util.io.BaseDataReader) ProcessEvent(com.intellij.execution.process.ProcessEvent)

Aggregations

ProcessAdapter (com.intellij.execution.process.ProcessAdapter)1 ProcessEvent (com.intellij.execution.process.ProcessEvent)1 BaseDataReader (com.intellij.util.io.BaseDataReader)1