Blame man3/sysconf.3

Packit 7cfc04
.\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
Packit 7cfc04
.\"
Packit 7cfc04
.\" %%%LICENSE_START(VERBATIM)
Packit 7cfc04
.\" Permission is granted to make and distribute verbatim copies of this
Packit 7cfc04
.\" manual provided the copyright notice and this permission notice are
Packit 7cfc04
.\" preserved on all copies.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Permission is granted to copy and distribute modified versions of this
Packit 7cfc04
.\" manual under the conditions for verbatim copying, provided that the
Packit 7cfc04
.\" entire resulting derived work is distributed under the terms of a
Packit 7cfc04
.\" permission notice identical to this one.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Since the Linux kernel and libraries are constantly changing, this
Packit 7cfc04
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
Packit 7cfc04
.\" responsibility for errors or omissions, or for damages resulting from
Packit 7cfc04
.\" the use of the information contained herein.  The author(s) may not
Packit 7cfc04
.\" have taken the same level of care in the production of this manual,
Packit 7cfc04
.\" which is licensed free of charge, as they might when working
Packit 7cfc04
.\" professionally.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Formatted or processed versions of this manual, if unaccompanied by
Packit 7cfc04
.\" the source, must acknowledge the copyright and authors of this work.
Packit 7cfc04
.\" %%%LICENSE_END
Packit 7cfc04
.\"
Packit 7cfc04
.\" Modified Sat Jul 24 17:51:42 1993 by Rik Faith (faith@cs.unc.edu)
Packit 7cfc04
.\" Modified Tue Aug 17 11:42:20 1999 by Ariel Scolnicov (ariels@compugen.co.il)
Packit 7cfc04
.TH SYSCONF 3  2017-11-26 "GNU" "Linux Programmer's Manual"
Packit 7cfc04
.SH NAME
Packit 7cfc04
sysconf \- get configuration information at run time
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.nf
Packit 7cfc04
.B #include <unistd.h>
Packit 7cfc04
.PP
Packit 7cfc04
.BI "long sysconf(int " "name" );
Packit 7cfc04
.fi
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
POSIX allows an application to test at compile or run time
Packit 7cfc04
whether certain options are supported, or what the value is
Packit 7cfc04
of certain configurable constants or limits.
Packit 7cfc04
.PP
Packit 7cfc04
At compile time this is done by including
Packit 7cfc04
.I <unistd.h>
Packit 7cfc04
and/or
Packit 7cfc04
.I <limits.h>
Packit 7cfc04
and testing the value of certain macros.
Packit 7cfc04
.PP
Packit 7cfc04
At run time, one can ask for numerical values using the present function
Packit 7cfc04
.BR sysconf ().
Packit 7cfc04
One can ask for numerical values that may depend
Packit 7cfc04
on the filesystem in which a file resides using
Packit 7cfc04
.BR fpathconf (3)
Packit 7cfc04
and
Packit 7cfc04
.BR pathconf (3).
Packit 7cfc04
One can ask for string values using
Packit 7cfc04
.BR confstr (3).
Packit 7cfc04
.PP
Packit 7cfc04
The values obtained from these functions are system configuration constants.
Packit 7cfc04
They do not change during the lifetime of a process.
Packit 7cfc04
.\" except that sysconf(_SC_OPEN_MAX) may change answer after a call
Packit 7cfc04
.\" to setrlimit( ) which changes the RLIMIT_NOFILE soft limit
Packit 7cfc04
.PP
Packit 7cfc04
For options, typically, there is a constant
Packit 7cfc04
.B _POSIX_FOO
Packit 7cfc04
that may be defined in
Packit 7cfc04
.IR <unistd.h> .
Packit 7cfc04
If it is undefined, one should ask at run time.
Packit 7cfc04
If it is defined to \-1, then the option is not supported.
Packit 7cfc04
If it is defined to 0, then relevant functions and headers exist,
Packit 7cfc04
but one has to ask at run time what degree of support is available.
Packit 7cfc04
If it is defined to a value other than \-1 or 0, then the option is
Packit 7cfc04
supported.
Packit 7cfc04
Usually the value (such as 200112L) indicates the year and month
Packit 7cfc04
of the POSIX revision describing the option.
Packit 7cfc04
Glibc uses the value 1
Packit 7cfc04
to indicate support as long as the POSIX revision has not been published yet.
Packit 7cfc04
.\" and 999 to indicate support for options no longer present in the latest
Packit 7cfc04
.\" standard. (?)
Packit 7cfc04
The
Packit 7cfc04
.BR sysconf ()
Packit 7cfc04
argument will be
Packit 7cfc04
.BR _SC_FOO .
Packit 7cfc04
For a list of options, see
Packit 7cfc04
.BR posixoptions (7).
Packit 7cfc04
.PP
Packit 7cfc04
For variables or limits, typically, there is a constant
Packit 7cfc04
.BR _FOO ,
Packit 7cfc04
maybe defined in
Packit 7cfc04
.IR <limits.h> ,
Packit 7cfc04
or
Packit 7cfc04
.BR _POSIX_FOO ,
Packit 7cfc04
maybe defined in
Packit 7cfc04
.IR <unistd.h> .
Packit 7cfc04
The constant will not be defined if the limit is unspecified.
Packit 7cfc04
If the constant is defined, it gives a guaranteed value, and
Packit 7cfc04
a greater value might actually be supported.
Packit 7cfc04
If an application wants to take advantage of values which may change
Packit 7cfc04
between systems, a call to
Packit 7cfc04
.BR sysconf ()
Packit 7cfc04
can be made.
Packit 7cfc04
The
Packit 7cfc04
.BR sysconf ()
Packit 7cfc04
argument will be
Packit 7cfc04
.BR _SC_FOO .
Packit 7cfc04
.SS POSIX.1 variables
Packit 7cfc04
We give the name of the variable, the name of the
Packit 7cfc04
.BR sysconf ()
Packit 7cfc04
argument used to inquire about its value,
Packit 7cfc04
and a short description.
Packit 7cfc04
.PP
Packit 7cfc04
First, the POSIX.1 compatible values.
Packit 7cfc04
.\" [for the moment: only the things that are unconditionally present]
Packit 7cfc04
.\" .TP
Packit 7cfc04
.\" .BR AIO_LISTIO_MAX " - " _SC_AIO_LISTIO_MAX
Packit 7cfc04
.\" (if _POSIX_ASYNCHRONOUS_IO)
Packit 7cfc04
.\" Maximum number of I/O operations in a single list I/O call.
Packit 7cfc04
.\" Must not be less than _POSIX_AIO_LISTIO_MAX.
Packit 7cfc04
.\" .TP
Packit 7cfc04
.\" .BR AIO_MAX " - " _SC_AIO_MAX
Packit 7cfc04
.\" (if _POSIX_ASYNCHRONOUS_IO)
Packit 7cfc04
.\" Maximum number of outstanding asynchronous I/O operations.
Packit 7cfc04
.\" Must not be less than _POSIX_AIO_MAX.
Packit 7cfc04
.\" .TP
Packit 7cfc04
.\" .BR AIO_PRIO_DELTA_MAX " - " _SC_AIO_PRIO_DELTA_MAX
Packit 7cfc04
.\" (if _POSIX_ASYNCHRONOUS_IO)
Packit 7cfc04
.\" The maximum amount by which a process can decrease its
Packit 7cfc04
.\" asynchronous I/O priority level from its own scheduling priority.
Packit 7cfc04
.\" Must be nonnegative.
Packit 7cfc04
.TP
Packit 7cfc04
.BR ARG_MAX " - " _SC_ARG_MAX
Packit 7cfc04
The maximum length of the arguments to the
Packit 7cfc04
.BR exec (3)
Packit 7cfc04
family of functions.
Packit 7cfc04
Must not be less than
Packit 7cfc04
.B _POSIX_ARG_MAX
Packit 7cfc04
(4096).
Packit 7cfc04
.TP
Packit 7cfc04
.BR CHILD_MAX " - " _SC_CHILD_MAX
Packit 7cfc04
The maximum number of simultaneous processes per user ID.
Packit 7cfc04
Must not be less than
Packit 7cfc04
.B _POSIX_CHILD_MAX
Packit 7cfc04
(25).
Packit 7cfc04
.TP
Packit 7cfc04
.BR HOST_NAME_MAX " - " _SC_HOST_NAME_MAX
Packit 7cfc04
Maximum length of a hostname, not including the terminating null byte,
Packit 7cfc04
as returned by
Packit 7cfc04
.BR gethostname (2).
Packit 7cfc04
Must not be less than
Packit 7cfc04
.B _POSIX_HOST_NAME_MAX
Packit 7cfc04
(255).
Packit 7cfc04
.TP
Packit 7cfc04
.BR LOGIN_NAME_MAX " - " _SC_LOGIN_NAME_MAX
Packit 7cfc04
Maximum length of a login name, including the terminating null byte.
Packit 7cfc04
Must not be less than
Packit 7cfc04
.B _POSIX_LOGIN_NAME_MAX
Packit 7cfc04
(9).
Packit 7cfc04
.TP
Packit 7cfc04
.BR NGROUPS_MAX " - " _SC_NGROUPS_MAX
Packit 7cfc04
Maximum number of supplementary group IDs.
Packit 7cfc04
.TP
Packit 7cfc04
.BR "" "clock ticks - " _SC_CLK_TCK
Packit 7cfc04
The number of clock ticks per second.
Packit 7cfc04
The corresponding variable is obsolete.
Packit 7cfc04
It was of course called
Packit 7cfc04
.BR CLK_TCK .
Packit 7cfc04
(Note: the macro
Packit 7cfc04
.B CLOCKS_PER_SEC
Packit 7cfc04
does not give information: it must equal 1000000.)
Packit 7cfc04
.TP
Packit 7cfc04
.BR OPEN_MAX " - " _SC_OPEN_MAX
Packit 7cfc04
The maximum number of files that a process can have open at any time.
Packit 7cfc04
Must not be less than
Packit 7cfc04
.B _POSIX_OPEN_MAX
Packit 7cfc04
(20).
Packit 7cfc04
.TP
Packit 7cfc04
.BR PAGESIZE " - " _SC_PAGESIZE
Packit 7cfc04
Size of a page in bytes.
Packit 7cfc04
Must not be less than 1.
Packit 7cfc04
(Some systems use PAGE_SIZE instead.)
Packit 7cfc04
.TP
Packit 7cfc04
.BR RE_DUP_MAX " - " _SC_RE_DUP_MAX
Packit 7cfc04
The number of repeated occurrences of a BRE permitted by
Packit 7cfc04
.BR regexec (3)
Packit 7cfc04
and
Packit 7cfc04
.BR regcomp (3).
Packit 7cfc04
Must not be less than
Packit 7cfc04
.B _POSIX2_RE_DUP_MAX
Packit 7cfc04
(255).
Packit 7cfc04
.TP
Packit 7cfc04
.BR STREAM_MAX " - " _SC_STREAM_MAX
Packit 7cfc04
The maximum number of streams that a process can have open at any
Packit 7cfc04
time.
Packit 7cfc04
If defined, it has the same value as the standard C macro
Packit 7cfc04
.BR FOPEN_MAX .
Packit 7cfc04
Must not be less than
Packit 7cfc04
.B _POSIX_STREAM_MAX
Packit 7cfc04
(8).
Packit 7cfc04
.TP
Packit 7cfc04
.BR SYMLOOP_MAX " - " _SC_SYMLOOP_MAX
Packit 7cfc04
The maximum number of symbolic links seen in a pathname before resolution
Packit 7cfc04
returns
Packit 7cfc04
.BR ELOOP .
Packit 7cfc04
Must not be less than
Packit 7cfc04
.B _POSIX_SYMLOOP_MAX
Packit 7cfc04
(8).
Packit 7cfc04
.TP
Packit 7cfc04
.BR TTY_NAME_MAX " - " _SC_TTY_NAME_MAX
Packit 7cfc04
The maximum length of terminal device name,
Packit 7cfc04
including the terminating null byte.
Packit 7cfc04
Must not be less than
Packit 7cfc04
.B _POSIX_TTY_NAME_MAX
Packit 7cfc04
(9).
Packit 7cfc04
.TP
Packit 7cfc04
.BR TZNAME_MAX " - " _SC_TZNAME_MAX
Packit 7cfc04
The maximum number of bytes in a timezone name.
Packit 7cfc04
Must not be less than
Packit 7cfc04
.B _POSIX_TZNAME_MAX
Packit 7cfc04
(6).
Packit 7cfc04
.TP
Packit 7cfc04
.BR _POSIX_VERSION " - " _SC_VERSION
Packit 7cfc04
indicates the year and month the POSIX.1 standard was approved in the
Packit 7cfc04
format
Packit 7cfc04
.BR YYYYMML ;
Packit 7cfc04
the value
Packit 7cfc04
.B 199009L
Packit 7cfc04
indicates the Sept. 1990 revision.
Packit 7cfc04
.SS POSIX.2 variables
Packit 7cfc04
Next, the POSIX.2 values, giving limits for utilities.
Packit 7cfc04
.TP
Packit 7cfc04
.BR BC_BASE_MAX " - " _SC_BC_BASE_MAX
Packit 7cfc04
indicates the maximum
Packit 7cfc04
.I obase
Packit 7cfc04
value accepted by the
Packit 7cfc04
.BR bc (1)
Packit 7cfc04
utility.
Packit 7cfc04
.TP
Packit 7cfc04
.BR BC_DIM_MAX " - " _SC_BC_DIM_MAX
Packit 7cfc04
indicates the maximum value of elements permitted in an array by
Packit 7cfc04
.BR bc (1).
Packit 7cfc04
.TP
Packit 7cfc04
.BR BC_SCALE_MAX " - " _SC_BC_SCALE_MAX
Packit 7cfc04
indicates the maximum
Packit 7cfc04
.I scale
Packit 7cfc04
value allowed by
Packit 7cfc04
.BR bc (1).
Packit 7cfc04
.TP
Packit 7cfc04
.BR BC_STRING_MAX " - " _SC_BC_STRING_MAX
Packit 7cfc04
indicates the maximum length of a string accepted by
Packit 7cfc04
.BR bc (1).
Packit 7cfc04
.TP
Packit 7cfc04
.BR COLL_WEIGHTS_MAX " - " _SC_COLL_WEIGHTS_MAX
Packit 7cfc04
indicates the maximum numbers of weights that can be assigned to an
Packit 7cfc04
entry of the
Packit 7cfc04
.B LC_COLLATE order
Packit 7cfc04
keyword in the locale definition file,
Packit 7cfc04
.TP
Packit 7cfc04
.BR EXPR_NEST_MAX " - " _SC_EXPR_NEST_MAX
Packit 7cfc04
is the maximum number of expressions which can be nested within
Packit 7cfc04
parentheses by
Packit 7cfc04
.BR expr (1).
Packit 7cfc04
.TP
Packit 7cfc04
.BR LINE_MAX " - " _SC_LINE_MAX
Packit 7cfc04
The maximum length of a utility's input line, either from
Packit 7cfc04
standard input or from a file.
Packit 7cfc04
This includes space for a trailing
Packit 7cfc04
newline.
Packit 7cfc04
.TP
Packit 7cfc04
.BR RE_DUP_MAX " - " _SC_RE_DUP_MAX
Packit 7cfc04
The maximum number of repeated occurrences of a regular expression when
Packit 7cfc04
the interval notation
Packit 7cfc04
.B \e{m,n\e}
Packit 7cfc04
is used.
Packit 7cfc04
.TP
Packit 7cfc04
.BR POSIX2_VERSION " - " _SC_2_VERSION
Packit 7cfc04
indicates the version of the POSIX.2 standard in the format of
Packit 7cfc04
YYYYMML.
Packit 7cfc04
.TP
Packit 7cfc04
.BR POSIX2_C_DEV " - " _SC_2_C_DEV
Packit 7cfc04
indicates whether the POSIX.2 C language development facilities are
Packit 7cfc04
supported.
Packit 7cfc04
.TP
Packit 7cfc04
.BR POSIX2_FORT_DEV " - " _SC_2_FORT_DEV
Packit 7cfc04
indicates whether the POSIX.2 FORTRAN development utilities are
Packit 7cfc04
supported.
Packit 7cfc04
.TP
Packit 7cfc04
.BR POSIX2_FORT_RUN " - " _SC_2_FORT_RUN
Packit 7cfc04
indicates whether the POSIX.2 FORTRAN run-time utilities are supported.
Packit 7cfc04
.TP
Packit 7cfc04
.BR _POSIX2_LOCALEDEF " - " _SC_2_LOCALEDEF
Packit 7cfc04
indicates whether the POSIX.2 creation of locates via
Packit 7cfc04
.BR localedef (1)
Packit 7cfc04
is supported.
Packit 7cfc04
.TP
Packit 7cfc04
.BR POSIX2_SW_DEV " - " _SC_2_SW_DEV
Packit 7cfc04
indicates whether the POSIX.2 software development utilities option is
Packit 7cfc04
supported.
Packit 7cfc04
.PP
Packit 7cfc04
These values also exist, but may not be standard.
Packit 7cfc04
.TP
Packit 7cfc04
.BR "" " - " _SC_PHYS_PAGES
Packit 7cfc04
The number of pages of physical memory.
Packit 7cfc04
Note that it is possible
Packit 7cfc04
for the product of this value and the value of
Packit 7cfc04
.B _SC_PAGESIZE
Packit 7cfc04
to overflow.
Packit 7cfc04
.TP
Packit 7cfc04
.BR "" " - " _SC_AVPHYS_PAGES
Packit 7cfc04
The number of currently available pages of physical memory.
Packit 7cfc04
.TP
Packit 7cfc04
.BR "" " - " _SC_NPROCESSORS_CONF
Packit 7cfc04
The number of processors configured.
Packit 7cfc04
See also
Packit 7cfc04
.BR get_nprocs_conf (3).
Packit 7cfc04
.TP
Packit 7cfc04
.BR "" " - " _SC_NPROCESSORS_ONLN
Packit 7cfc04
The number of processors currently online (available).
Packit 7cfc04
See also
Packit 7cfc04
.BR get_nprocs_conf (3).
Packit 7cfc04
.SH RETURN VALUE
Packit 7cfc04
The return value of
Packit 7cfc04
.BR sysconf ()
Packit 7cfc04
is one of the following:
Packit 7cfc04
.IP * 3
Packit 7cfc04
On error, \-1 is returned and
Packit 7cfc04
.I errno
Packit 7cfc04
is set to indicate the cause of the error
Packit 7cfc04
(for example,
Packit 7cfc04
.BR EINVAL ,
Packit 7cfc04
indicating that
Packit 7cfc04
.I name
Packit 7cfc04
is invalid).
Packit 7cfc04
.IP *
Packit 7cfc04
If
Packit 7cfc04
.I name
Packit 7cfc04
corresponds to a maximum or minimum limit, and that limit is indeterminate,
Packit 7cfc04
\-1 is returned and
Packit 7cfc04
.I errno
Packit 7cfc04
is not changed.
Packit 7cfc04
(To distinguish an indeterminate limit from an error, set
Packit 7cfc04
.I errno
Packit 7cfc04
to zero before the call, and then check whether
Packit 7cfc04
.I errno
Packit 7cfc04
is nonzero when \-1 is returned.)
Packit 7cfc04
.IP *
Packit 7cfc04
If
Packit 7cfc04
.I name
Packit 7cfc04
corresponds to an option,
Packit 7cfc04
a positive value is returned if the option is supported,
Packit 7cfc04
and \-1 is returned if the option is not supported.
Packit 7cfc04
.IP *
Packit 7cfc04
Otherwise,
Packit 7cfc04
the current value of the option or limit is returned.
Packit 7cfc04
This value will not be more restrictive than
Packit 7cfc04
the corresponding value that was described to the application in
Packit 7cfc04
.I <unistd.h>
Packit 7cfc04
or
Packit 7cfc04
.I <limits.h>
Packit 7cfc04
when the application was compiled.
Packit 7cfc04
.SH ERRORS
Packit 7cfc04
.TP
Packit 7cfc04
.B EINVAL
Packit 7cfc04
.I name
Packit 7cfc04
is invalid.
Packit 7cfc04
.SH ATTRIBUTES
Packit 7cfc04
For an explanation of the terms used in this section, see
Packit 7cfc04
.BR attributes (7).
Packit 7cfc04
.TS
Packit 7cfc04
allbox;
Packit 7cfc04
lb lb lb
Packit 7cfc04
l l l.
Packit 7cfc04
Interface	Attribute	Value
Packit 7cfc04
T{
Packit 7cfc04
.BR sysconf ()
Packit 7cfc04
T}	Thread safety	MT-Safe env
Packit 7cfc04
.TE
Packit 7cfc04
.SH CONFORMING TO
Packit 7cfc04
POSIX.1-2001, POSIX.1-2008.
Packit 7cfc04
.SH BUGS
Packit 7cfc04
It is difficult to use
Packit 7cfc04
.B ARG_MAX
Packit 7cfc04
because it is not specified how much of the argument space for
Packit 7cfc04
.BR exec (3)
Packit 7cfc04
is consumed by the user's environment variables.
Packit 7cfc04
.PP
Packit 7cfc04
Some returned values may be huge; they are not suitable for allocating
Packit 7cfc04
memory.
Packit 7cfc04
.SH SEE ALSO
Packit 7cfc04
.BR bc (1),
Packit 7cfc04
.BR expr (1),
Packit 7cfc04
.BR getconf (1),
Packit 7cfc04
.BR locale (1),
Packit 7cfc04
.BR confstr (3),
Packit 7cfc04
.BR fpathconf (3),
Packit 7cfc04
.BR pathconf (3),
Packit 7cfc04
.BR posixoptions (7)
Packit 7cfc04
.SH COLOPHON
Packit 7cfc04
This page is part of release 4.15 of the Linux
Packit 7cfc04
.I man-pages
Packit 7cfc04
project.
Packit 7cfc04
A description of the project,
Packit 7cfc04
information about reporting bugs,
Packit 7cfc04
and the latest version of this page,
Packit 7cfc04
can be found at
Packit 7cfc04
\%https://www.kernel.org/doc/man\-pages/.