On Wed, 4 Feb 2026 11:12:28 GMT, Kieran Farrell <[email protected]> wrote:
>> src/hotspot/os/bsd/os_bsd.cpp line 2608:
>>
>>> 2606:
>>> 2607: nfiles = res / sizeof(struct proc_fdinfo);
>>> 2608: if (nfiles >= MAX_SAFE_FDS) {
>>
>> About MAX_SAFE_FDS:
>>
>> What is really returned by `pid_for_task`?
>>
>> If return values > MAX_SAFE_FDS are possible, would that be the reliable
>> "number of open fds" ? If so, why not print that instead of ">1024"? In
>> fact, if so, why even bother returning an array at all, why not make the
>> array 1-element-sized only, pro format? All we are interested in is the
>> number.
>
> proc_pidinfo allocates a buffer to hold a struct proc_fdinfo for each FD. To
> avoid using malloc and allocating potentially large amounts of memory in a
> signal-handling context, we decided to use a pre-allocated struct and read
> onto that.
>
> proc_pidinfo will return once the buffer is full, in that case we have to
> assume the actual number of open FDs is >= 1024
the only way to count the number of open FDs on macOs is to allocate an array
of proc_fdinfo structs and count the total number
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27971#discussion_r2763476172