in appengine-plugins-core/src/main/java/com/google/cloud/tools/managedcloudsdk/process/ProcessExecutor.java [57:93]
public int run(
List<String> command,
@Nullable Path workingDirectory,
@Nullable Map<String, String> environment,
AsyncStreamHandler stdout,
AsyncStreamHandler stderr)
throws IOException, InterruptedException {
logger.fine("Running command : " + command);
if (workingDirectory != null) {
logger.fine("In working directory : " + workingDirectory.toString());
}
if (environment != null && environment.size() > 0) {
logger.fine("With environment : " + environment);
}
// Builds the command to execute.
ProcessBuilder processBuilder = processBuilderFactory.createProcessBuilder();
processBuilder.command(command);
if (workingDirectory != null) {
processBuilder.directory(workingDirectory.toFile());
}
if (environment != null) {
processBuilder.environment().putAll(environment);
}
Process process = processBuilder.start();
stdout.handleStream(process.getInputStream());
stderr.handleStream(process.getErrorStream());
try {
return process.waitFor();
} catch (InterruptedException ex) {
process.destroy();
throw ex; // rethrow after cleanup
}
}