SYSCONF(3) | Library Functions Manual | SYSCONF(3) |
sysconf
— get
configurable system variables
Standard C Library (libc, -lc)
#include
<unistd.h>
long
sysconf
(int
name);
This interface is defined by IEEE Std 1003.1-1988 (“POSIX.1”). A far more complete interface is available using sysctl(3).
The
sysconf
()
function provides a method for applications to determine the current value
of a configurable system limit or option variable. The
name argument specifies the system variable to be
queried. Symbolic constants for each name value are found in the include
file <unistd.h>
. Shell
programmers who need access to these parameters should use the
getconf(1) utility.
The available values are as follows:
_SC_ARG_MAX
_SC_CHILD_MAX
_SC_CLK_TCK
_SC_IOV_MAX
_SC_NGROUPS_MAX
_SC_NPROCESSORS_CONF
_SC_NPROCESSORS_ONLN
_SC_OPEN_MAX
_SC_PAGESIZE
_SC_STREAM_MAX
_SC_TZNAME_MAX
_SC_JOB_CONTROL
_SC_SAVED_IDS
_SC_VERSION
_SC_BC_BASE_MAX
_SC_BC_DIM_MAX
_SC_BC_SCALE_MAX
_SC_BC_STRING_MAX
_SC_COLL_WEIGHTS_MAX
_SC_EXPR_NEST_MAX
_SC_LINE_MAX
_SC_RE_DUP_MAX
_SC_2_VERSION
_SC_2_C_BIND
_SC_2_C_DEV
_SC_2_CHAR_TERM
_SC_2_FORT_DEV
_SC_2_FORT_RUN
_SC_2_LOCALEDEF
_SC_2_SW_DEV
_SC_2_UPE
These values also exist, but may not be standard:
_SC_PHYS_PAGES
_SC_PAGESIZE
will overflow a
long in some configurations on a 32bit machine.If the call to sysconf
() is not
successful, -1 is returned and errno is set
appropriately. Otherwise, if the variable is associated with functionality
that is not supported, -1 is returned and errno is not
modified. Otherwise, the current variable value is returned.
The sysconf
() function may fail and set
errno for any of the errors specified for the library
function sysctl(3). In addition, the following error may
be reported:
EINVAL
]Except for the fact that values returned by
sysconf
() may change over the lifetime of the
calling process, this function conforms to IEEE Std
1003.1-1988 (“POSIX.1”).
The sysconf
() function first appeared in
4.4BSD.
The value for _SC_STREAM_MAX is a minimum maximum, and required to be the same as ANSI C's FOPEN_MAX, so the returned value is a ridiculously small and misleading number.
December 14, 2006 | Mac OS X 12 |