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)
Tue, Apr 2, 12:35 AM
Unknown Object (File)
Feb 8 2024, 1:55 AM
Unknown Object (File)
Jan 20 2024, 7:42 PM
Unknown Object (File)
Jan 9 2024, 8:30 PM
Unknown Object (File)
Dec 27 2023, 5:32 AM
Unknown Object (File)
Dec 27 2023, 5:29 AM
Unknown Object (File)
Dec 23 2023, 4:45 AM
Unknown Object (File)
Aug 15 2023, 3:46 PM
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.