| 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_UPEThese 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 | macOS 15.6 |