Page MenuHomeFreeBSD

getdtablesize(2): add legacy note and suggest using getrlimit instead
Needs RevisionPublic

Authored by emaste on Aug 31 2016, 3:17 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Oct 22, 6:04 AM
Unknown Object (File)
Wed, Oct 22, 6:04 AM
Unknown Object (File)
Tue, Oct 21, 5:59 PM
Unknown Object (File)
Sep 4 2025, 8:12 AM
Unknown Object (File)
Aug 11 2025, 5:09 AM
Unknown Object (File)
Jul 10 2025, 5:45 AM
Unknown Object (File)
Jun 28 2025, 2:11 PM
Unknown Object (File)
Jun 17 2025, 1:51 AM
Subscribers
None

Details

Reviewers
jilles
wblock

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

emaste retitled this revision from to getdtablesize(2): add legacy note and suggest using getrlimit instead.
emaste updated this object.
emaste edited the test plan for this revision. (Show Details)
emaste added reviewers: wblock, jilles.
jilles requested changes to this revision.Aug 31 2016, 5:18 PM
jilles edited edge metadata.

A few years ago, a change was made to getdtablesize() so it is no longer equivalent to getrlimit(RLIMIT_NOFILE).rlim_cur: getdtablesize() reflects rctl(8), while getrlimit(RLIMIT_NOFILE) and sysconf(_SC_OPEN_MAX) do not. Therefore, it may be useful to use getdtablesize() if what is desired is as accurate a file descriptor limit as possible.

I don't think rlimits are supposed to change (after their initial setting) other than via setrlimit(), so it may not be possible to fix this.

sysconf(_SC_OPEN_MAX) could be follow rctl, although it is a POSIX violation if the value changes other than because of a setrlimit(RLIMIT_NOFILE) call.

This revision now requires changes to proceed.Aug 31 2016, 5:18 PM

A few years ago, a change was made to getdtablesize() so it is no longer equivalent to getrlimit(RLIMIT_NOFILE).

That said, as far as I can tell POSIX used to claim getdtablesize as a legacy interface equivalent to getrlimit(RLIMIT_NOFILE) and it's now gone entirely. So I'm not sure what we ought to do.