SYSCONF(3) | Linux Programmer's Manual | SYSCONF(3) |
sysconf - get configuration information at run time
#include <unistd.h>
long sysconf(int name);
POSIX allows an application to test at compile or run time whether certain options are supported, or what the value is of certain configurable constants or limits.
At compile time this is done by including <unistd.h> and/or <limits.h> and testing the value of certain macros.
At run time, one can ask for numerical values using the present function sysconf(). One can ask for numerical values that may depend on the filesystem in which a file resides using fpathconf(3) and pathconf(3). One can ask for string values using confstr(3).
The values obtained from these functions are system configuration constants. They do not change during the lifetime of a process.
For options, typically, there is a constant _POSIX_FOO that may be defined in <unistd.h>. If it is undefined, one should ask at run time. If it is defined to -1, then the option is not supported. If it is defined to 0, then relevant functions and headers exist, but one has to ask at run time what degree of support is available. If it is defined to a value other than -1 or 0, then the option is supported. Usually the value (such as 200112L) indicates 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 has not been published yet. The sysconf() argument will be _SC_FOO. For a list of options, see posixoptions(7).
For variables or limits, typically, there is 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. If an application wants to take advantage of values which may change between systems, a call to sysconf() can be made. The sysconf() argument will be _SC_FOO.
We give the name of the variable, the name of the sysconf() argument used to inquire about its value, and a short description.
First, the POSIX.1 compatible values.
Next, the POSIX.2 values, giving limits for utilities.
These values also exist, but may not be standard.
The return value of sysconf() is one of the following:
For an explanation of the terms used in this section, see attributes(7).
Interface | Attribute | Value |
sysconf () | Thread safety | MT-Safe env |
POSIX.1-2001, POSIX.1-2008.
It is difficult to use ARG_MAX because it is not specified how much of the argument space for exec(3) is consumed by the user's environment variables.
Some returned values may be huge; they are not suitable for allocating memory.
bc(1), expr(1), getconf(1), locale(1), confstr(3), fpathconf(3), pathconf(3), posixoptions(7)
This page is part of release 5.10 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/.
2019-05-09 | GNU |