scala/scala — pull request #3920 by rubyu (2014-08-07 08:08:24+00:00)
Title: SI-7350 Prevent resource leaks in PipedProcesses.runAndExitValue()

This patch fixes some problems in `PipedProcesses` as listed bellow:

- `source` and `sink` leak when b.run() fails at [ProcessImpl.scala#L132](https://github.com/scala/scala/blob/538aa22ec8144430e778a34bc749eccb6f5dbf4c/src/library/scala/sys/process/ProcessImpl.scala#L132). ([SI-7350](https://issues.scala-lang.org/browse/SI-7350))

- `source`, `sink` and `second` leak when a.run() fails at [ProcessImpl.scala#L133](https://github.com/scala/scala/blob/538aa22ec8144430e778a34bc749eccb6f5dbf4c/src/library/scala/sys/process/ProcessImpl.scala#L133). ([SI-7350](https://issues.scala-lang.org/browse/SI-7350))

- `source` and `sink` leak when `Process.exitValue()` interrupted in [ProcessImpl.scala#L135](https://github.com/scala/scala/blob/538aa22ec8144430e778a34bc749eccb6f5dbf4c/src/library/scala/sys/process/ProcessImpl.scala#L135). ([SI-7350](https://issues.scala-lang.org/browse/SI-7350))

- `first` and `second` do not properly connected when `None` putted to `currentSink` before `sink` receive `Some(InputStream)` at [ProcessImpl.scala#L138](https://github.com/scala/scala/blob/538aa22ec8144430e778a34bc749eccb6f5dbf4c/src/library/scala/sys/process/ProcessImpl.scala#L138). ([SI-8768](https://issues.scala-lang.org/browse/SI-8768))

and, a broblem in [BasicIO.scala#L222](https://github.com/scala/scala/blob/538aa22ec8144430e778a34bc749eccb6f5dbf4c/src/library/scala/sys/process/BasicIO.scala#L222) that

-`InputStream` and `OutputStream` never throw `InterruptedException`, but `BasicIO.transferFully` trying to catch it at [package.scala#L238](https://github.com/scala/scala/blob/159baa268e5cc14b50bf29a40fff922e36dd7bc9/src/library/scala/sys/process/package.scala#L238).

I guess this originally intented to catch `InterruptedIOException`.