aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/shell
diff options
context:
space:
mode:
authorGravatar Lukacs Berki <lberki@google.com>2016-06-24 07:24:11 +0000
committerGravatar Lukacs Berki <lberki@google.com>2016-06-24 08:12:39 +0000
commitacd4f07a1d5f5d588087e5918c6009d26150d57e (patch)
tree068004165899a08a8773ca9622ded4398c8ed830 /src/main/java/com/google/devtools/build/lib/shell
parent33d7bdb12541b2516d9798eb91df3d677ed3245c (diff)
Do not try to read from the stdout/stderr streams of destroyed processes.
According to https://bugs.openjdk.java.net/browse/JDK-4311711 , the behavior is undefined and it reproducibly results in hangs on Windows. This makes Ctrl-C on be able to interrupt Bazel during the execution phase, too. There are no guarantees about actually killing the child processes, though: Process.destroy() apparently leaves some child processes running. Unfortunately, Java doesn't offer a solution to this, so we'll have to resort to native code in some way. -- MOS_MIGRATED_REVID=125758911
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/shell')
-rw-r--r--src/main/java/com/google/devtools/build/lib/shell/Command.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/shell/Command.java b/src/main/java/com/google/devtools/build/lib/shell/Command.java
index 1301fa1780..e7417e9543 100644
--- a/src/main/java/com/google/devtools/build/lib/shell/Command.java
+++ b/src/main/java/com/google/devtools/build/lib/shell/Command.java
@@ -824,7 +824,12 @@ public final class Command {
log.finer(status.toString());
try {
- outErr.waitForCompletion();
+ if (Thread.interrupted()) {
+ outErr.cancel();
+ Thread.currentThread().interrupt();
+ } else {
+ outErr.waitForCompletion();
+ }
} catch (IOException ioe) {
CommandResult noOutputResult =
new CommandResult(CommandResult.EMPTY_OUTPUT,