Browse Source

Merge branch '2.2.x'

Closes gh-18941
pull/18962/head
Andy Wilkinson 6 years ago
parent
commit
0b733fe3dd
  1. 24
      spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/RunProcess.java

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

@ -113,13 +113,33 @@ public class RunProcess { @@ -113,13 +113,33 @@ public class RunProcess {
* @return {@code true} if stopped
*/
public boolean handleSigInt() {
// if the process has just ended, probably due to this SIGINT, consider handled.
if (hasJustEnded()) {
if (allowChildToHandleSigInt()) {
return true;
}
return doKill();
}
private boolean allowChildToHandleSigInt() {
Process process = this.process;
if (process == null) {
return true;
}
long end = System.currentTimeMillis() + 5000;
while (System.currentTimeMillis() < end) {
if (!process.isAlive()) {
return true;
}
try {
Thread.sleep(500);
}
catch (InterruptedException ex) {
Thread.currentThread().interrupt();
return false;
}
}
return false;
}
/**
* Kill this process.
*/

Loading…
Cancel
Save