Process trees and termination
stuart.marks at oracle.com
Thu Jun 26 21:40:24 UTC 2014
On 6/26/14 7:23 AM, roger riggs wrote:
> On 6/26/2014 4:55 AM, Peter Levart wrote:
>> - Will there be a guarantee that ProcessHandle objects returned from factory
>> methods: [...]
>> representing those processes that were started by ProcessBuilder API are
>> actually the same Process objects that were returned from the ProcessBuilder
> The initial design does not have them returning Process instances.
> Process instances are capabilities and their reference accessibility is
> currently controlled
> by the code that created the Process. If ProcessHandle gave out those Process
> it would break existing encapsulation.
This is an interesting point about the undesirability of leaking Process
instances. I initially thought the relationship between ProcessHandle and
Process objects would be unspecified, and possibly left to the implementation.
But based on your comments, it sounds like the PH factories are **prohibited**
from returning any instances of Process. Thus we'd have:
Process proc = new ProcessBuilder(...).start();
ProcessHandle ph = ProcessHandle.of(proc.getPid());
assert !(ph instanceof Process);
It seems like it would be good idea to add this restriction to the specification.
More information about the core-libs-dev