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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms