Commit 02de6e35 authored by Andy Wilkinson's avatar Andy Wilkinson

Remove signal handling race condition from RunProcess

Fixes #1061
parent 0b7836b4
...@@ -30,6 +30,7 @@ import org.springframework.util.ReflectionUtils; ...@@ -30,6 +30,7 @@ import org.springframework.util.ReflectionUtils;
* *
* @author Phillip Webb * @author Phillip Webb
* @author Dave Syer * @author Dave Syer
* @author Andy Wilkinson
* @since 1.1.0 * @since 1.1.0
*/ */
public class RunProcess { public class RunProcess {
...@@ -59,9 +60,10 @@ public class RunProcess { ...@@ -59,9 +60,10 @@ public class RunProcess {
builder.redirectErrorStream(true); builder.redirectErrorStream(true);
boolean inheritedIO = inheritIO(builder); boolean inheritedIO = inheritIO(builder);
try { try {
this.process = builder.start(); Process process = builder.start();
this.process = process;
if (!inheritedIO) { if (!inheritedIO) {
redirectOutput(this.process); redirectOutput(process);
} }
SignalUtils.attachSignalHandler(new Runnable() { SignalUtils.attachSignalHandler(new Runnable() {
@Override @Override
...@@ -70,15 +72,10 @@ public class RunProcess { ...@@ -70,15 +72,10 @@ public class RunProcess {
} }
}); });
try { try {
this.process.waitFor(); return process.waitFor();
} }
catch (InterruptedException ex) { catch (InterruptedException ex) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
}
try {
return this.process.exitValue();
}
catch (IllegalThreadStateException e) {
return 1; return 1;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment