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, May 12, 8:39 PM
Unknown Object (File)
Sun, May 10, 12:23 AM
Unknown Object (File)
Fri, May 8, 9:47 PM
Unknown Object (File)
Tue, May 5, 10:19 AM
Unknown Object (File)
Sun, May 3, 10:48 AM
Unknown Object (File)
Mon, Apr 20, 12:50 AM
Unknown Object (File)
Mon, Apr 20, 12:50 AM
Unknown Object (File)
Sun, Apr 19, 7:14 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.