Implement timeouts on Windows.

Makes #1664 much less acute.

--
MOS_MIGRATED_REVID=130750731
diff --git a/src/main/java/com/google/devtools/build/lib/shell/TerminationStatus.java b/src/main/java/com/google/devtools/build/lib/shell/TerminationStatus.java
index c8ee015..2f75b5e 100644
--- a/src/main/java/com/google/devtools/build/lib/shell/TerminationStatus.java
+++ b/src/main/java/com/google/devtools/build/lib/shell/TerminationStatus.java
@@ -29,6 +29,7 @@
 public final class TerminationStatus {
 
   private final int waitResult;
+  private final boolean timedout;
 
   /**
    * Values taken from the glibc strsignal(3) function.
@@ -79,8 +80,9 @@
    *
    * @param waitResult the value returned by {@link java.lang.Process#waitFor}.
    */
-  public TerminationStatus(int waitResult) {
+  public TerminationStatus(int waitResult, boolean timedout) {
     this.waitResult = waitResult;
+    this.timedout = timedout;
   }
 
   /**
@@ -110,7 +112,14 @@
    * Returns true iff the process exited normally.
    */
   public boolean exited() {
-    return waitResult < SIGNAL_1 || waitResult > SIGNAL_63;
+    return !timedout && (waitResult < SIGNAL_1 || waitResult > SIGNAL_63);
+  }
+
+  /**
+   * Returns true if the process timed out.
+   */
+  public boolean timedout() {
+    return timedout;
   }
 
   /**
@@ -128,7 +137,7 @@
    * if exited() returns true.
    */
   public int getTerminatingSignal() {
-    if (exited()) {
+    if (exited() || timedout) {
       throw new IllegalStateException("getTerminatingSignal() not defined");
     }
     return waitResult - SIGNAL_1 + 1;
@@ -139,16 +148,20 @@
    * e.g. "Exit 1" or "Hangup".
    */
   public String toShortString() {
-    return exited()
-      ? ("Exit " + getExitCode())
-      : (getSignalString(getTerminatingSignal()));
+    return exited() ? "Exit " + getExitCode()
+      : timedout ? "Timeout"
+      : getSignalString(getTerminatingSignal());
   }
 
   @Override
   public String toString() {
-    return exited()
-      ? ("Process exited with status " + getExitCode())
-      : ("Process terminated by signal " + getTerminatingSignal());
+    if (exited()) {
+      return "Process exited with status " + getExitCode();
+    } else if (timedout) {
+      return "Timed out";
+    } else {
+      return "Process terminated by signal " + getTerminatingSignal();
+    }
   }
 
   @Override