Fix possible subprocess leak.

If closing the output stream fails and throws an IOException, we'd not run
the cleanup code to kill the just-started subprocess.

I have no proof that this is causing problems, but this is wrong by visual
inspection so it, in theory, could be a problem.

RELNOTES: None.
PiperOrigin-RevId: 310346950
diff --git a/src/main/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunner.java
index 065b522..ef9886b 100644
--- a/src/main/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunner.java
+++ b/src/main/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunner.java
@@ -392,12 +392,12 @@
                 .profile(ProfilerTask.PROCESS_TIME, spawn.getResourceOwner().getMnemonic())) {
           needCleanup = true;
           Subprocess subprocess = subprocessBuilder.start();
-          subprocess.getOutputStream().close();
           try {
+            subprocess.getOutputStream().close();
             subprocess.waitFor();
             terminationStatus =
                 new TerminationStatus(subprocess.exitValue(), subprocess.timedout());
-          } catch (InterruptedException e) {
+          } catch (InterruptedException | IOException e) {
             subprocess.destroyAndWait();
             throw e;
           }