| 1 |
'\" t |
| 2 |
.\" Copyright 1993, Rickard E. Faith <[email protected]> |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 6 |
.\" |
| 7 |
.TH getdtablesize 3 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
getdtablesize \- get file descriptor table size |
| 10 |
.SH LIBRARY |
| 11 |
Standard C library |
| 12 |
.RI ( libc ,\~ \-lc ) |
| 13 |
.SH SYNOPSIS |
| 14 |
.nf |
| 15 |
.B #include <unistd.h> |
| 16 |
.P |
| 17 |
.B int getdtablesize(void); |
| 18 |
.fi |
| 19 |
.P |
| 20 |
.RS -4 |
| 21 |
Feature Test Macro Requirements for glibc (see |
| 22 |
.BR feature_test_macros (7)): |
| 23 |
.RE |
| 24 |
.P |
| 25 |
.BR getdtablesize (): |
| 26 |
.nf |
| 27 |
Since glibc 2.20: |
| 28 |
_DEFAULT_SOURCE || ! (_POSIX_C_SOURCE >= 200112L) |
| 29 |
glibc 2.12 to glibc 2.19: |
| 30 |
_BSD_SOURCE || ! (_POSIX_C_SOURCE >= 200112L) |
| 31 |
Before glibc 2.12: |
| 32 |
_BSD_SOURCE || _XOPEN_SOURCE >= 500 |
| 33 |
.\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED |
| 34 |
.fi |
| 35 |
.SH DESCRIPTION |
| 36 |
.BR getdtablesize () |
| 37 |
returns the maximum number of files a process can have open, |
| 38 |
one more than the largest possible value for a file descriptor. |
| 39 |
.SH RETURN VALUE |
| 40 |
The current limit on the number of open files per process. |
| 41 |
.SH ERRORS |
| 42 |
On Linux, |
| 43 |
.BR getdtablesize () |
| 44 |
can return any of the errors described for |
| 45 |
.BR getrlimit (2); |
| 46 |
see VERSIONS below. |
| 47 |
.SH ATTRIBUTES |
| 48 |
For an explanation of the terms used in this section, see |
| 49 |
.BR attributes (7). |
| 50 |
.TS |
| 51 |
allbox; |
| 52 |
lbx lb lb |
| 53 |
l l l. |
| 54 |
Interface Attribute Value |
| 55 |
T{ |
| 56 |
.na |
| 57 |
.nh |
| 58 |
.BR getdtablesize () |
| 59 |
T} Thread safety MT-Safe |
| 60 |
.TE |
| 61 |
.SH VERSIONS |
| 62 |
The glibc version of |
| 63 |
.BR getdtablesize () |
| 64 |
calls |
| 65 |
.BR getrlimit (2) |
| 66 |
and returns the current |
| 67 |
.B RLIMIT_NOFILE |
| 68 |
limit, or |
| 69 |
.B OPEN_MAX |
| 70 |
when that fails. |
| 71 |
.\" The libc4 and libc5 versions return |
| 72 |
.\" .B OPEN_MAX |
| 73 |
.\" (set to 256 since Linux 0.98.4). |
| 74 |
.P |
| 75 |
Portable applications should employ |
| 76 |
.I sysconf(_SC_OPEN_MAX) |
| 77 |
instead of this call. |
| 78 |
.SH STANDARDS |
| 79 |
None. |
| 80 |
.SH HISTORY |
| 81 |
SVr4, 4.4BSD |
| 82 |
(first appeared in 4.2BSD). |
| 83 |
.SH SEE ALSO |
| 84 |
.BR close (2), |
| 85 |
.BR dup (2), |
| 86 |
.BR getrlimit (2), |
| 87 |
.BR open (2) |