On Sat, 18 Apr 2026 16:52:37 GMT, Roger Riggs <[email protected]> wrote:
> The purpose of the `do{...} while` loop is to sort the descendants to the
> beginning of the arrays. If the desired result for pid == 0 is to return all
> processes, then it should not be wasting time selecting and sorting. Just
> return a Stream of all of the ProcessHandles (or skip the sorting).
I wouldn't say that is desired behavior. It's just what is observed but is
platform specific and undocumented. I'm not sure special casing pid == 0 in the
shared code is a good idea. What if the other platforms have similar behavior,
but for different pid values? I think also checking before dereferencing an out
of range index value is still prudent regardless.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/30763#issuecomment-4278601271