Process.waitFor() may hang if subprocess has live descendants (lnx)

Martin Buchholz martinrb at google.com
Tue Aug 31 05:38:34 UTC 2010


On Mon, Aug 30, 2010 at 18:21, David Holmes <David.Holmes at oracle.com> wrote:

> Hi Martin,
>
> My only minor concern with this is the potential change in timing. Is it
> possible that a test will assume the streams are closed when waitFor
> returns? If so I guess we need to update the test.
>
>
This change reverts to the historical behavior.

One cannot really close any user-visible stream before waitFor returns,
because there may be buffered data remaining to be read, at both the java
and os pipe level.

(this stuff is all surprisingly tricky... further improvements are possible,
but are going to be much more work)

Martin

Cheers,
> David
>
> Martin Buchholz said the following on 08/31/10 04:38:
>
>> This is a bug report with fix.
>>
>> My code in UNIXProcess.java.linux introduced a hang if the subprocess
>> terminates, but it has remaining descendants that keep the pipe file
>> descriptors open.
>>
>> Here's a fix:
>>
>> http://cr.openjdk.java.net/~martin/webrevs/openjdk7/ProcessHang/<http://cr.openjdk.java.net/%7Emartin/webrevs/openjdk7/ProcessHang/><
>> http://cr.openjdk.java.net/%7Emartin/webrevs/openjdk7/ProcessHang/>
>>
>>
>> Please review.
>>
>> Alan, there are remaining (pre-existing) thorny issues with proper
>> handling of process streams and asynchronous close, that we might want to
>> discuss someday.
>>
>>
>>
>> Martin
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/core-libs-dev/attachments/20100830/6f700f88/attachment.html>


More information about the core-libs-dev mailing list