@Test public void abend() throws Exception { Path sh = assumeLinuxSh(); int exit = launcher().launch(sh, "-c", "exit 1"); assertThat(exit, is(not(0))); }
@Override public int launch(Path command, List<String> arguments) throws IOException, InterruptedException { List<String> commandLine = new ArrayList<>(); commandLine.add(command.toAbsolutePath().toString()); commandLine.addAll(arguments); ProcessBuilder builder = new ProcessBuilder(commandLine); builder.directory(workingDir.toFile()); builder.environment().clear(); builder.environment().putAll(environment); if (LOG.isInfoEnabled()) { LOG.info("exec: {}", builder.command().stream() .map(it -> '"' + it + '"') .collect(Collectors.joining(", "))); } Process process = builder.start(); try { return handle(process, Optional.ofNullable(command.getFileName()) .map(Path::toString) .orElse("N/A")); } finally { process.destroy(); } }
BasicCommandLauncher implements CommandLauncher { @Override public int launch(Path command, List<String> arguments) throws IOException, InterruptedException { List<String> commandLine = new ArrayList<>(); commandLine.add(command.toAbsolutePath().toString()); commandLine.addAll(arguments); ProcessBuilder builder = new ProcessBuilder(commandLine); builder.directory(workingDir.toFile()); builder.environment().clear(); builder.environment().putAll(environment); if (LOG.isInfoEnabled()) { LOG.info("exec: {}", builder.command().stream() .map(it -> '"' + it + '"') .collect(Collectors.joining(", "))); } Process process = builder.start(); try { return handle(process, Optional.ofNullable(command.getFileName()) .map(Path::toString) .orElse("N/A")); } finally { process.destroy(); } } }
BasicCommandLauncher implements CommandLauncher { @Override public int launch(Path command, List<String> arguments) throws IOException, InterruptedException { List<String> commandLine = new ArrayList<>(); commandLine.add(command.toAbsolutePath().toString()); commandLine.addAll(arguments); ProcessBuilder builder = new ProcessBuilder(commandLine); builder.directory(workingDir.toFile()); builder.environment().clear(); builder.environment().putAll(environment); if (LOG.isInfoEnabled()) { LOG.info("exec: {}", builder.command().stream() .map(it -> '"' + it + '"') .collect(Collectors.joining(", "))); } Process process = builder.start(); try { return handle(process, Optional.ofNullable(command.getFileName()) .map(Path::toString) .orElse("N/A")); } finally { process.destroy(); } } BasicCommandLauncher(Path workingDir, Map<String, String> environment);  BasicCommandLauncher(OutputConsumer output, Path workingDir, Map<String, String> environment); }
BasicCommandLauncher implements CommandLauncher { @Override public int launch(Path command, List<String> arguments) throws IOException, InterruptedException { List<String> commandLine = new ArrayList<>(); commandLine.add(command.toAbsolutePath().toString()); commandLine.addAll(arguments); ProcessBuilder builder = new ProcessBuilder(commandLine); builder.directory(workingDir.toFile()); builder.environment().clear(); builder.environment().putAll(environment); if (LOG.isInfoEnabled()) { LOG.info("exec: {}", builder.command().stream() .map(it -> '"' + it + '"') .collect(Collectors.joining(", "))); } Process process = builder.start(); try { return handle(process, Optional.ofNullable(command.getFileName()) .map(Path::toString) .orElse("N/A")); } finally { process.destroy(); } } BasicCommandLauncher(Path workingDir, Map<String, String> environment);  BasicCommandLauncher(OutputConsumer output, Path workingDir, Map<String, String> environment); @Override int launch(Path command, List<String> arguments); }
BasicCommandLauncher implements CommandLauncher { @Override public int launch(Path command, List<String> arguments) throws IOException, InterruptedException { List<String> commandLine = new ArrayList<>(); commandLine.add(command.toAbsolutePath().toString()); commandLine.addAll(arguments); ProcessBuilder builder = new ProcessBuilder(commandLine); builder.directory(workingDir.toFile()); builder.environment().clear(); builder.environment().putAll(environment); if (LOG.isInfoEnabled()) { LOG.info("exec: {}", builder.command().stream() .map(it -> '"' + it + '"') .collect(Collectors.joining(", "))); } Process process = builder.start(); try { return handle(process, Optional.ofNullable(command.getFileName()) .map(Path::toString) .orElse("N/A")); } finally { process.destroy(); } } BasicCommandLauncher(Path workingDir, Map<String, String> environment);  BasicCommandLauncher(OutputConsumer output, Path workingDir, Map<String, String> environment); @Override int launch(Path command, List<String> arguments);  }