commit
fc3f6a930d
|
@ -113,13 +113,33 @@ public class RunProcess {
|
||||||
* @return {@code true} if stopped
|
* @return {@code true} if stopped
|
||||||
*/
|
*/
|
||||||
public boolean handleSigInt() {
|
public boolean handleSigInt() {
|
||||||
// if the process has just ended, probably due to this SIGINT, consider handled.
|
if (allowChildToHandleSigInt()) {
|
||||||
if (hasJustEnded()) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return doKill();
|
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.
|
* Kill this process.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue