getdtablesize(3)
β¨ getdtablesize(3) β¨
okay bestie, this is getdtablesize from the Library Functions Manual, and honestly? she's a little vintage, a little overlooked, and lowkey kinda iconic. let's get into it π
πΈ NAME πΈ
getdtablesize β get file descriptor table size
π LIBRARY π
Standard C library (libc, -lc) π«Ά
π SYNOPSIS π
#include <unistd.h>
int getdtablesize(void);
π¦ Feature Test Macro Requirements for glibc
(psst β see feature_test_macros(7) for the full tea π)
getdtablesize():
- Since glibc 2.20:
_DEFAULT_SOURCE || ! (_POSIX_C_SOURCE >= 200112L)
- glibc 2.12 to glibc 2.19:
_BSD_SOURCE || ! (_POSIX_C_SOURCE >= 200112L)
- Before glibc 2.12:
_BSD_SOURCE || _XOPEN_SOURCE >= 500
likeβ¦ the macro requirements genuinely have lore. they evolve. they grow. they went through eras. π§
π DESCRIPTION π
getdtablesize() returns the maximum number of files a process can have open β which is exactly one more than the largest possible value for a file descriptor. so if your biggest fd number is n, the answer is n + 1. it's giving "one extra seat at the table just in case." π
π RETURN VALUE π
The current limit on the number of open files per process. that's your number. that's the vibe check result. β¨
π ERRORS π
On Linux, getdtablesize() can return any of the errors described for getrlimit(2) β head down to VERSIONS below for why that's even a thing π
π ATTRIBUTES π
For an explanation of the terms used in this section, see attributes(7).
getdtablesize()β Thread safety: MT-Safe
(no cap, she's MT-Safe, we love a thread-safe queen π«Ά)
π VERSIONS π
The glibc version of getdtablesize() calls getrlimit(2) and returns the current RLIMIT_NOFILE limit, or OPEN_MAX when that fails.
β οΈ okay so real talk: portable applications should employ sysconf(_SC_OPEN_MAX) instead of this call. she's cute but she's not the one to take on the road trip. π
β STANDARDS β
None.
(yeah. none. she's not standardized bestie. she's just there, doing her thing, living her truth. π )
π¦ HISTORY π¦
SVr4, 4.4BSD (first appeared in 4.2BSD).
absolute OG behavior, first appeared in 4.2BSD β not me getting emotional about a libc function π₯Ή
πΈ SEE ALSO πΈ
close(2), dup(2), getrlimit(2), open(2)
and that's the whole page, bestie!! go forth and count your file descriptors responsibly π
mwah π β this was getdtablesize(3) from Linux man-pages 6.20, dated 2026-02-08. periodt. β¨π
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- Copyright 1993, Rickard E. Faith <faith@cs.unc.edu>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms