When validating workers, also check that the worker hasn't died in the meanwhile.

Workers can die due to bugs in the tools or the wrappers or because something entirely different killed them. We cannot prevent that, but we can avoid trying to execute an action on a worker that's already dead.

This lets a build continue if a worker has died before it gets used for an action, but still fails the build if the worker dies during the action. Since the worker pool already has a check that newly created workers are valid, a worker that crashes will either get a failure from the worker pool, have an action fail, or make progress

RELNOTES: None
PiperOrigin-RevId: 322754088
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 d7ce117..771100d 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
@@ -31,15 +31,20 @@
   /**
    * Returns the exit value of the process.
    *
-   * <p>Throws {@code IOException} if the process has not terminated yet.
+   * <p>Throws {@code IllegalThreadStateException} if the process has not terminated yet.
    */
   int exitValue();
 
   /**
    * Returns the if the process has finished.
+   *
+   * <p>This may cause the process to be destroyed as a side effect, for example due to a timeout.
    */
   boolean finished();
 
+  /** Returns true if the process is still alive. Does not block or cause any side effects. */
+  boolean isAlive();
+
   /**
    * Returns if the process timed out.
    */