--- src\main\org\apache\tools\ant\taskdefs\StreamPumper.java Thu Oct 11 22:58:30 2001 +++ StreamPumper.java Tue Dec 04 11:47:05 2001 @@ -85,23 +85,35 @@ this.os = os; } - + /** + * read method with possibility to be interrupted, when blocking is set to false + */ + public int read(InputStream is, byte[] buf, boolean blocking) throws InterruptedException, IOException { + if (!blocking) { + while (is.available()==0) { + Thread.sleep(SLEEP); + } + } + return is.read(buf); + } + /** * Copies data from the input stream to the output stream. * - * Terminates as soon as the input stream is closed or an error occurs. + * Terminates as soon as the input stream is closed or an error occurs (or interrupted on Windows). */ public void run() { final byte[] buf = new byte[SIZE]; - + // nonblocking read only for Windows solving Ant bug #5003 + boolean blocking = System.getProperty("os.name").toLowerCase().indexOf("windows")<0; + // for other systems use blocking read, because on OS/2 systems with IBM JDK 1.3.x is bug in InputStream.isAvailable() int length; try { - while ((length = is.read(buf)) > 0) { + while ((!Thread.currentThread().isInterrupted())&&((length = read(is, buf, blocking)) > 0)) { os.write(buf, 0, length); - try { - Thread.sleep(SLEEP); - } catch (InterruptedException e) {} + Thread.sleep(SLEEP); } - } catch(IOException e) {} + } catch(IOException e) { + } catch (InterruptedException e) {} } } --- src\main\org\apache\tools\ant\taskdefs\PumpStreamHandler.java Thu Oct 11 22:58:28 2001 +++ PumpStreamHandler.java Tue Dec 04 11:54:16 2001 @@ -107,9 +107,11 @@ public void stop() { + inputThread.interrupt(); try { inputThread.join(); } catch(InterruptedException e) {} + errorThread.interrupt(); try { errorThread.join(); } catch(InterruptedException e) {}