Process API Updates (JEP 102)

Roger Riggs Roger.Riggs at Oracle.com
Wed Mar 26 00:27:01 UTC 2014


Hi Florian,

On 3/25/14 5:18 AM, Florian Weimer wrote:
> On 03/24/2014 10:11 PM, roger riggs wrote:
>
>>  From the scope of the JEP, a fairly simple API seems sufficient.
>>   - Enumerate the direct children
>>   - The rest of the functions are similar to Process
>>     - to terminate a process, forcibly and normally
>>     - to destroy a process and all of its children recursively
>>     - to check if one is alive
>>     - to waitFor for termination and retrieve the exit status
>
> On Linux, I think you need to use obscure mechanisms to make this 
> iteration reliable (cgroups perhaps).  There is no openpid() or 
> similar mechanism that allows you to obtain a stable handle.
Given that processes are asynchronous in creation and termination, I 
don't think
'reliable' listing is possible.  In a pathological case, processes can 
be created
as fast/faster than they can be terminated.
>
> Somewhat relatedly, it would make sense to make Process 
> auto-closeable, so that you can make sure that no non-Java resources 
> are retained. Right now, this seems to require calling 
> destroyForcibly().waitFor().
That's worth looking at a close() method could have that compound behavior.
>
> It would be nice if there was a way to directly pipe the output of one 
> process to the input of another process.  I think that even with Java 
> 8, this still needs an explicit copy loop.
That's similar to other requests to directly feed or consume from the 
subprocess from
a file or pipe.

Thanks, Roger





More information about the core-libs-dev mailing list