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.
@@ -392,12 +392,12 @@ public class LocalSpawnRunner implements SpawnRunner {
.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;
}
