Skip to content

Commit 02de6e3

Browse files
committed
Remove signal handling race condition from RunProcess
Fixes #1061
1 parent 0b7836b commit 02de6e3

File tree

1 file changed

+6
-9
lines changed
  • spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools

1 file changed

+6
-9
lines changed

spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/RunProcess.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@
2727

2828
/**
2929
* Utility used to run a process.
30-
*
30+
*
3131
* @author Phillip Webb
3232
* @author Dave Syer
33+
* @author Andy Wilkinson
3334
* @since 1.1.0
3435
*/
3536
public class RunProcess {
@@ -59,9 +60,10 @@ protected int run(Collection<String> args) throws IOException {
5960
builder.redirectErrorStream(true);
6061
boolean inheritedIO = inheritIO(builder);
6162
try {
62-
this.process = builder.start();
63+
Process process = builder.start();
64+
this.process = process;
6365
if (!inheritedIO) {
64-
redirectOutput(this.process);
66+
redirectOutput(process);
6567
}
6668
SignalUtils.attachSignalHandler(new Runnable() {
6769
@Override
@@ -70,15 +72,10 @@ public void run() {
7072
}
7173
});
7274
try {
73-
this.process.waitFor();
75+
return process.waitFor();
7476
}
7577
catch (InterruptedException ex) {
7678
Thread.currentThread().interrupt();
77-
}
78-
try {
79-
return this.process.exitValue();
80-
}
81-
catch (IllegalThreadStateException e) {
8279
return 1;
8380
}
8481
}

0 commit comments

Comments
 (0)