diff --git a/src/main/org/apache/tools/ant/taskdefs/Execute.java b/src/main/org/apache/tools/ant/taskdefs/Execute.java index d37ba861f..51bc4654f 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Execute.java +++ b/src/main/org/apache/tools/ant/taskdefs/Execute.java @@ -475,6 +475,7 @@ public class Execute { watchdog.stop(); } streamHandler.stop(); + closeStreams(process); if (watchdog != null) { watchdog.checkException(); @@ -536,13 +537,6 @@ public class Execute { setExitValue(process.exitValue()); } catch (InterruptedException e) { process.destroy(); - } finally { - try { - process.getInputStream().close(); - process.getOutputStream().close(); - process.getErrorStream().close(); - } catch (IOException eyeOhEx) { - } } } @@ -659,6 +653,25 @@ public class Execute { } } + /** + * Close the streams belonging to the given Process. + * @param process the Process. + */ + public static void closeStreams(Process process) { + try { + process.getInputStream().close(); + } catch (IOException eyeOhEx) { + } + try { + process.getOutputStream().close(); + } catch (IOException eyeOhEx) { + } + try { + process.getErrorStream().close(); + } catch (IOException eyeOhEx) { + } + } + /** * This method is VMS specific and used by getProcEnvironment(). *