Hello all!
Would you please help review a fix?
http://bugs.sun.com/view_bug.do?bug_id=8024521
As of JDK 1.7, ProcessPipeInputStream tries to drain the InputStream
when the process exits.
However, it is racing with application code that could be closing the
inputstream at the same time.
This can lead to processExited() operating on the wrong underlying file.
The test included into the webrev demonstrates exactly that: Due to the
race, the draining thread can suddenly start to read a huge file which
will cause OutOfMemoryException.
Here's the webrev with a simple fix, which synchronizes close() and
processExited():
http://cr.openjdk.java.net/~igerasim/8024521/0/webrev/
It's important to note that this simple fix isn't complete.
It only protects from the race when the file descriptor is closed by a
call to Process#getInputStream().close().
The file descriptor can still be asynchronously closed in some other
way, for example by calling to the native close() function.
Sincerely yours,
Ivan Gerasimov