Skip to content

Commit

Permalink
Merge branch '2.1.x' into 2.2.x
Browse files Browse the repository at this point in the history
Closes gh-18940
  • Loading branch information
wilkinsona committed Nov 8, 2019
2 parents 84f682d + 5765cfe commit fc3f6a9
Showing 1 changed file with 22 additions and 2 deletions.
Expand Up @@ -113,13 +113,33 @@ public Process getRunningProcess() {
* @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.
*/
Expand Down

0 comments on commit fc3f6a9

Please sign in to comment.