aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/shell
diff options
context:
space:
mode:
authorGravatar Lukacs Berki <lberki@google.com>2016-07-01 14:32:53 +0000
committerGravatar Lukacs Berki <lberki@google.com>2016-07-04 07:18:05 +0000
commit0451cf0b5a16688bb56396af276a6ef4ebbe5d4d (patch)
tree5c05180bea38d3898e0a2d4f8b5217e3e6bf8933 /src/main/java/com/google/devtools/build/lib/shell
parent6382bfd45ee39f97809a185216a183686e1a8f1b (diff)
Add an implementation for SubprocessFactory based on the new JNI interface to Windows process management.
With this change, Bazel can build itself using native Windows process management and Ctrl-C works in server mode as expected. Yay! Flipping the flag will come in a separate change that's easy to roll back if need be. -- MOS_MIGRATED_REVID=126408264
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.java12
-rw-r--r--src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java15
-rw-r--r--src/main/java/com/google/devtools/build/lib/shell/Subprocess.java9
3 files changed, 23 insertions, 13 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 e5a958c185..35d3b8720e 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
@@ -705,14 +705,7 @@ public final class Command {
@Override
public boolean isDone() {
- try {
- // exitValue seems to be the only non-blocking call for
- // checking process liveness.
- process.exitValue();
- return true;
- } catch (IllegalThreadStateException e) {
- return false;
- }
+ return process.finished();
}
};
}
@@ -880,7 +873,8 @@ public final class Command {
try {
while (true) {
try {
- return new TerminationStatus(process.waitFor());
+ process.waitFor();
+ return new TerminationStatus(process.exitValue());
} catch (InterruptedException ie) {
wasInterrupted = true;
if (killSubprocessOnInterrupt) {
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 c09a24a704..ab3acd4e44 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
@@ -49,8 +49,19 @@ public class JavaSubprocessFactory implements Subprocess.Factory {
}
@Override
- public int waitFor() throws InterruptedException {
- return process.waitFor();
+ public boolean finished() {
+ try {
+ // this seems to be the only non-blocking call for checking liveness
+ process.exitValue();
+ return true;
+ } catch (IllegalThreadStateException e) {
+ return false;
+ }
+ }
+
+ @Override
+ public void waitFor() throws InterruptedException {
+ process.waitFor();
}
@Override
diff --git a/src/main/java/com/google/devtools/build/lib/shell/Subprocess.java b/src/main/java/com/google/devtools/build/lib/shell/Subprocess.java
index 99e55776ff..f8a8a553e7 100644
--- a/src/main/java/com/google/devtools/build/lib/shell/Subprocess.java
+++ b/src/main/java/com/google/devtools/build/lib/shell/Subprocess.java
@@ -42,14 +42,19 @@ public interface Subprocess {
/**
* Returns the exit value of the process.
*
- * <p>Throws {@code IllegalThreadStateException} if the process has not terminated yet.
+ * <p>Throws {@code IOException} if the process has not terminated yet.
*/
int exitValue();
/**
+ * Returns the if the process has finished.
+ */
+ boolean finished();
+
+ /**
* Waits for the process to finish.
*/
- int waitFor() throws InterruptedException;
+ void waitFor() throws InterruptedException;
/**
* Returns a stream into which data can be written that the process will get on its stdin.