// handle IO of spawned process
Execution<ProcessResult> processConsumer = Tasks.chain(spawnedProcess, ConsumeProcessOutputTask.class)
.programName(command.getProgramName()).interaction(interaction).execute();
// wait for process to finish IO
ProcessResult result = processConsumer.await();
if (spawnedProcess.hasFailed()) {
throw new ExecutionException("Invocation of \"{0}\" failed with {1}", new Object[] {
command,
result.exitValue() });
}
return result;
}