Skip to content

Commit d0c322d

Browse files
committed
Merge branch '2.2.x'
Closes spring-projectsgh-18941
2 parents c5aa68d + 29cc669 commit d0c322d

File tree

1 file changed

+22
-2
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools

1 file changed

+22
-2
lines changed

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,33 @@ public Process getRunningProcess() {
113113
* @return {@code true} if stopped
114114
*/
115115
public boolean handleSigInt() {
116-
// if the process has just ended, probably due to this SIGINT, consider handled.
117-
if (hasJustEnded()) {
116+
if (allowChildToHandleSigInt()) {
118117
return true;
119118
}
120119
return doKill();
121120
}
122121

122+
private boolean allowChildToHandleSigInt() {
123+
Process process = this.process;
124+
if (process == null) {
125+
return true;
126+
}
127+
long end = System.currentTimeMillis() + 5000;
128+
while (System.currentTimeMillis() < end) {
129+
if (!process.isAlive()) {
130+
return true;
131+
}
132+
try {
133+
Thread.sleep(500);
134+
}
135+
catch (InterruptedException ex) {
136+
Thread.currentThread().interrupt();
137+
return false;
138+
}
139+
}
140+
return false;
141+
}
142+
123143
/**
124144
* Kill this process.
125145
*/

0 commit comments

Comments
 (0)