Add ExitStatus to Command.run()

The main difference for now is the removal of the --nohup
(slightly hacky) option in TestCommand. Now a TestCommand
can signal to its caller that it wants to be hung up.

Fixes gh-975
This commit is contained in:
Dave Syer
2014-05-28 16:39:05 +01:00
parent 5e3cc95ccf
commit 3c6dfb72c5
21 changed files with 155 additions and 46 deletions

View File

@@ -48,11 +48,11 @@ public class RunProcess {
this.command = command;
}
public void run(String... args) throws IOException {
run(Arrays.asList(args));
public int run(String... args) throws IOException {
return run(Arrays.asList(args));
}
protected void run(Collection<String> args) throws IOException {
protected int run(Collection<String> args) throws IOException {
ProcessBuilder builder = new ProcessBuilder(this.command);
builder.command().addAll(args);
builder.redirectErrorStream(true);
@@ -74,6 +74,12 @@ public class RunProcess {
catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
try {
return this.process.exitValue();
}
catch (IllegalThreadStateException e) {
return 1;
}
}
finally {
this.endTime = System.currentTimeMillis();