Section (3) sysconf
sysconf — get configuration information at run time
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
and testing the value of certain macros.
At run time, one can ask for numerical values using the
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
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
_SC_FOO. For a list of
options, see posixoptions(7).
For variables or limits, typically, there is a constant
_FOO, maybe defined in
_POSIX_FOO, maybe defined in
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
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.
The maximum length of the arguments to the exec(3) family of functions. Must not be less than
The maximum number of simultaneous processes per user ID. Must not be less than
Maximum length of a hostname, not including the terminating null byte, as returned by gethostname(2). Must not be less than
Maximum length of a login name, including the terminating null byte. Must not be less than
Maximum number of supplementary group IDs.
- clock ticks -
The number of clock ticks per second. The corresponding variable is obsolete. It was of course called
CLOCKS_PER_SECdoes not give information: it must equal 1000000.
The maximum number of files that a process can have open at any time. Must not be less than
Size of a page in bytes. Must not be less than 1.
A synonym for
PAGE_SIZEare specified in POSIX.)
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 macro
FOPEN_MAX. Must not be less than
The maximum number of symbolic links seen in a pathname before resolution returns ELOOP. Must not be less than
The maximum length of terminal device name, including the terminating null byte. Must not be less than
The maximum number of bytes in a timezone name. Must not be less than
indicates the year and month the POSIX.1 standard was approved in the format
YYYYMML; the value
199009Lindicates the Sept. 1990 revision.
Next, the POSIX.2 values, giving limits for utilities.
indicates the maximum
obasevalue accepted by the bc(1) utility.
indicates the maximum value of elements permitted in an array by bc(1).
indicates the maximum
scalevalue allowed by bc(1).
indicates the maximum length of a string accepted by bc(1).
indicates the maximum numbers of weights that can be assigned to an entry of the LC_COLLATE order keyword in the locale definition file,
is the maximum number of expressions which can be nested within parentheses by expr(1).
The maximum length of a utility_zsingle_quotesz_s input line, either from standard input or from a file. This includes space for a trailing newline.
The maximum number of repeated occurrences of a regular expression when the interval notation
indicates the version of the POSIX.2 standard in the format of YYYYMML.
indicates whether the POSIX.2 C language development facilities are supported.
indicates whether the POSIX.2 FORTRAN development utilities are supported.
indicates whether the POSIX.2 FORTRAN run-time utilities are supported.
indicates whether the POSIX.2 creation of locates via localedef(1) is supported.
indicates whether the POSIX.2 software development utilities option is supported.
These values also exist, but may not be standard.
The number of pages of physical memory. Note that it is possible for the product of this value and the value of
The number of currently available pages of physical memory.
The number of processors configured. See also get_nprocs_conf(3).
The number of processors currently online (available). See also get_nprocs_conf(3).
The return value of
sysconf() is one of the following:
On error, −1 is returned and
errnois set to indicate the cause of the error (for example, EINVAL, indicating that
namecorresponds to a maximum or minimum limit, and that limit is indeterminate, −1 is returned and
errnois not changed. (To distinguish an indeterminate limit from an error, set
errnoto zero before the call, and then check whether
errnois nonzero when −1 is returned.)
namecorresponds to an option, a positive value is returned if the option is supported, and −1 is 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
>when the application was compiled.
For an explanation of the terms used in this section, see attributes(7).
||Thread safety||MT-Safe env|
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_zsingle_quotesz_s environment variables.
Some returned values may be huge; they are not suitable for allocating memory.
This page is part of release 5.04 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
Copyright (c) 1993 by Thomas Koenig (ig25rz.uni-karlsruhe.de)
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the
entire resulting derived work is distributed under the terms of a
permission notice identical to this one.
Since the Linux kernel and libraries are constantly changing, this
manual page may be incorrect or out-of-date. The author(s) assume no
responsibility for errors or omissions, or for damages resulting from
the use of the information contained herein. The author(s) may not
have taken the same level of care in the production of this manual,
which is licensed free of charge, as they might when working
Formatted or processed versions of this manual, if unaccompanied by
the source, must acknowledge the copyright and authors of this work.
Modified Sat Jul 24 17:51:42 1993 by Rik Faith (faithcs.unc.edu)
Modified Tue Aug 17 11:42:20 1999 by Ariel Scolnicov (arielscompugen.co.il)