JEP 425 (Virtual Threads) - Cancellation
Roger Riggs
roger.riggs at oracle.com
Tue May 3 13:40:51 UTC 2022
Hi,
It might be worth filing a separate issue on the Process API issue.
Note that the Process stream implementations take pains to NOT close the
streams
until the parent has a chance to read any pending input.
When the process dies the OS should close the stream from the child
side, causing EOF to the parent.
But there may be more to look at there.
Regards, Roger
On 02/05/2022 20:48, David Holmes wrote:
>>
>> That part seems to be only about sockets, while I would like to see
>> the other
>> most common I/O operations to address the problem. Sure, as David
>> mentioned
>> in a previous email, it is not a trivial change (I'm not even
>> proposing that this JEP
>> should include it, just that this would be a good time to release a
>> cancellation
>> JEP building on this virtual thread JEP), but still the current state
>> is a major
>> inconvenience. In fact, I just recently learned that, there can be a
>> scenario where
>> if you block on an `InputStream` (stdout/stderr of started process)
>> of a started
>> `Process`, then you will be trapped in the blocking call forever (even
>> destroy/destroyForcibly of the process won't help), unless you steal
>> and close
>> the underlying `FileChannel` via reflection.
>
> On the surface that seems like a bug in the Process API. Termination
> of the child process should be detected and the captured streams closed.
>
> David
More information about the jdk-dev
mailing list