sysconf(3)
โจ NAME โจ
sysconf โ get configuration information at run time ๐ซถ (it's a Library Functions Manual situation, and yes we are in our libc era)
๐ LIBRARY ๐
Standard C library (libc, -lc) ๐
๐ธ SYNOPSIS ๐ธ
#include <unistd.h>
long sysconf(int name);
๐ DESCRIPTION ๐
okay so here's the tea, bestie โ POSIX lets your app do a lil vibe check โ either at compile time or at run time โ to find out whether certain options are supported, or what the actual value of certain configurable constants or limits is.
At compile time, you do that by including <unistd.h> and/or <limits.h> and testing the value of certain macros โจ
At run time, you can ask for numerical values using the present function, sysconf(). If you want numerical values that may depend on the filesystem where a file lives, that's fpathconf(3) and pathconf(3) territory ๐ And if you want string values, you go hit up confstr(3).
The values you get from these functions are system configuration constants. Lowkey important: they do not change during the lifetime of a process. no cap ๐
For options, typically there's a constant _POSIX_FOO that may be defined in <unistd.h>. Here's how to read it:
- if it's undefined, you should ask at run time ๐
- if it's defined to
-1, the option is not supported ๐ - if it's defined to
0, then the relevant functions and headers exist, but you still have to ask at run time what degree of support is actually available - if it's defined to a value other than
-1or0, then the option is supported ๐
Usually that value (like 200112L) tells you the year and month of the POSIX revision describing the option. glibc uses the value 1 to indicate support as long as the POSIX revision hasn't been published yet. In these cases the sysconf() argument will be _SC_FOO. For a list of options, go peek at posixoptions(7) ๐
For variables or limits, typically there's a constant _FOO, maybe defined in <limits.h>, or _POSIX_FOO, maybe defined in <unistd.h>. The constant will not be defined if the limit is unspecified. If the constant is defined, it gives a guaranteed value, and a greater value might actually be supported ๐ So if your app wants to take advantage of values that may change between systems, you call sysconf(). The sysconf() argument will be _SC_FOO.
๐ POSIX.1 variables ๐
We give you the name of the variable, the name of the sysconf() argument used to inquire about its value, and a short description. First up, the POSIX.1 compatible values ๐
ARG_MAX-_SC_ARG_MAXโ the maximum length of the arguments to theexec(3)family of functions. Must not be less than_POSIX_ARG_MAX(4096).CHILD_MAX-_SC_CHILD_MAXโ the maximum number of simultaneous processes per user ID. Must not be less than_POSIX_CHILD_MAX(25).HOST_NAME_MAX-_SC_HOST_NAME_MAXโ maximum length of a hostname, not including the terminating null byte, as returned bygethostname(2). Must not be less than_POSIX_HOST_NAME_MAX(255).LOGIN_NAME_MAX-_SC_LOGIN_NAME_MAXโ maximum length of a login name, including the terminating null byte. Must not be less than_POSIX_LOGIN_NAME_MAX(9).NGROUPS_MAX-_SC_NGROUPS_MAXโ maximum number of supplementary group IDs.clock ticks-_SC_CLK_TCKโ the number of clock ticks per second. The corresponding variable is obsolete ๐ชฆ It was of course calledCLK_TCK. (Note: the macroCLOCKS_PER_SECdoes not give information: it must equal1000000.)OPEN_MAX-_SC_OPEN_MAXโ the maximum number of files that a process can have open at any time. Must not be less than_POSIX_OPEN_MAX(20).PAGESIZE-_SC_PAGESIZEโ size of a page in bytes. Must not be less than1.PAGE_SIZE-_SC_PAGE_SIZEโ a synonym forPAGESIZE/_SC_PAGESIZE. (BothPAGESIZEandPAGE_SIZEare specified in POSIX.)RE_DUP_MAX-_SC_RE_DUP_MAXโ the number of repeated occurrences of a BRE permitted byregexec(3)andregcomp(3). Must not be less than_POSIX2_RE_DUP_MAX(255).STREAM_MAX-_SC_STREAM_MAXโ the maximum number of streams that a process can have open at any time. If defined, it has the same value as the standard C macroFOPEN_MAX. Must not be less than_POSIX_STREAM_MAX(8).SYMLOOP_MAX-_SC_SYMLOOP_MAXโ the maximum number of symbolic links seen in a pathname before resolution returnsELOOP. Must not be less than_POSIX_SYMLOOP_MAX(8).TTY_NAME_MAX-_SC_TTY_NAME_MAXโ the maximum length of terminal device name, including the terminating null byte. Must not be less than_POSIX_TTY_NAME_MAX(9).TZNAME_MAX-_SC_TZNAME_MAXโ the maximum number of bytes in a timezone name. Must not be less than_POSIX_TZNAME_MAX(6)._POSIX_VERSION-_SC_VERSIONโ indicates the year and month the POSIX.1 standard was approved in the formatYYYYMML; the value199009Lindicates the Sept. 1990 revision.
๐ฆ POSIX.2 variables ๐ฆ
Next up, the POSIX.2 values, which give limits for utilities ๐ง
BC_BASE_MAX-_SC_BC_BASE_MAXโ indicates the maximumobasevalue accepted by thebc(1)utility.BC_DIM_MAX-_SC_BC_DIM_MAXโ indicates the maximum value of elements permitted in an array bybc(1).BC_SCALE_MAX-_SC_BC_SCALE_MAXโ indicates the maximumscalevalue allowed bybc(1).BC_STRING_MAX-_SC_BC_STRING_MAXโ indicates the maximum length of a string accepted bybc(1).COLL_WEIGHTS_MAX-_SC_COLL_WEIGHTS_MAXโ indicates the maximum numbers of weights that can be assigned to an entry of theLC_COLLATEorder keyword in the locale definition file.EXPR_NEST_MAX-_SC_EXPR_NEST_MAXโ is the maximum number of expressions which can be nested within parentheses byexpr(1).LINE_MAX-_SC_LINE_MAXโ the maximum length of a utility's input line, either from standard input or from a file. This includes space for a trailing newline.RE_DUP_MAX-_SC_RE_DUP_MAXโ the maximum number of repeated occurrences of a regular expression when the interval notation\{m,n\}is used.POSIX2_VERSION-_SC_2_VERSIONโ indicates the version of the POSIX.2 standard in the format ofYYYYMML.POSIX2_C_DEV-_SC_2_C_DEVโ indicates whether the POSIX.2 C language development facilities are supported.POSIX2_FORT_DEV-_SC_2_FORT_DEVโ indicates whether the POSIX.2 FORTRAN development utilities are supported.POSIX2_FORT_RUN-_SC_2_FORT_RUNโ indicates whether the POSIX.2 FORTRAN run-time utilities are supported._POSIX2_LOCALEDEF-_SC_2_LOCALEDEFโ indicates whether the POSIX.2 creation of locales vialocaledef(1)is supported.POSIX2_SW_DEV-_SC_2_SW_DEVโ indicates whether the POSIX.2 software development utilities option is supported.
These values also exist, but may not be standard ๐โจ
_SC_PHYS_PAGESโ the number of pages of physical memory. Note that it is possible for the product of this value and the value of_SC_PAGESIZEto overflow ๐ญ_SC_AVPHYS_PAGESโ the number of currently available pages of physical memory._SC_NPROCESSORS_CONFโ the number of processors configured. See alsoget_nprocs_conf(3)._SC_NPROCESSORS_ONLNโ the number of processors currently online (available). See alsoget_nprocs_conf(3).
๐ RETURN VALUE ๐
The return value of sysconf() is one of the following, bestie:
- On error,
-1is returned anderrnois set to indicate the error (for example,EINVAL, indicating thatnameis invalid). - If
namecorresponds to a maximum or minimum limit, and that limit is indeterminate,-1is returned anderrnois not changed. (To distinguish an indeterminate limit from an error, seterrnoto zero before the call, and then check whethererrnois nonzero when-1is returned.) ๐ต๏ธโโ๏ธ - If
namecorresponds to an option, a positive value is returned if the option is supported, and-1is returned if the option is not supported. - Otherwise, the current value of the option or limit is returned. This value will not be more restrictive than the corresponding value that was described to the application in
<unistd.h>or<limits.h>when the application was compiled. ๐
๐ ERRORS ๐
EINVALโnameis invalid.
๐ ATTRIBUTES ๐
For an explanation of the terms used in this section, see attributes(7). Here's the lil chart, translated to vibes:
- Interface:
sysconf() - Attribute: Thread safety
- Value:
MT-Safe env
๐ STANDARDS ๐
POSIX.1-2008. periodt ๐
๐ฐ๏ธ HISTORY ๐ฐ๏ธ
POSIX.1-2001.
๐ BUGS ๐
- It is difficult to use
ARG_MAXbecause it is not specified how much of the argument space forexec(3)is consumed by the user's environment variables. ๐ญ - Some returned values may be huge; they are not suitable for allocating memory. ๐จ
fr fr do not go malloc-ing based on these numbers, that's how you get got ๐
๐ฅ SEE ALSO ๐ฅ
bc(1), expr(1), getconf(1), locale(1), confstr(3), fpathconf(3), pathconf(3), posixoptions(7)
and that's the whole page, bestie ๐ซถ this was pulled straight from Linux man-pages 6.20, dated 2026-02-08 โ the sysconf(3) era, slay ๐โจ๐
๐ฆ 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, Thomas Koenig <ig25@rz.uni-karlsruhe.de>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms