aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/shell
diff options
context:
space:
mode:
authorGravatar dannark <dannark@google.com>2018-04-04 14:02:13 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-04-04 14:03:33 -0700
commit2a5512fa3041df96b140e96a30112d5137be8b63 (patch)
tree3e73629ba36153f846b6ab125308c1779c013d94 /src/main/java/com/google/devtools/build/lib/shell
parent7520dcce42217c8076b06ed88c0e4e04ed99a0f4 (diff)
Internal change
PiperOrigin-RevId: 191642942
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/shell')
-rw-r--r--src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java b/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java
index bfc867d991..7647d17dd3 100644
--- a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java
+++ b/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java
@@ -54,15 +54,20 @@ public class JavaSubprocessFactory implements SubprocessFactory {
@Override
public boolean finished() {
- if (deadlineMillis > 0
- && System.currentTimeMillis() > deadlineMillis
- && deadlineExceeded.compareAndSet(false, true)) {
- // We use compareAndSet here to avoid calling destroy multiple times. Note that destroy
- // returns immediately, and we don't want to wait in this method.
- process.destroy();
+ try {
+ if (deadlineMillis > 0
+ && System.currentTimeMillis() > deadlineMillis
+ && deadlineExceeded.compareAndSet(false, true)) {
+ // We use compareAndSet here to avoid calling destroy multiple times. Note that destroy
+ // returns immediately, and we don't want to wait in this method.
+ process.destroy();
+ }
+ // this seems to be the only non-blocking call for checking liveness
+ process.exitValue();
+ return true;
+ } catch (IllegalThreadStateException e) {
+ return false;
}
- // this seems to be the only non-blocking call for checking liveness
- return !process.isAlive();
}
@Override