NAME
sysconf — get
configurable system variables
SYNOPSIS
#include <unistd.h> long int sysconf(int name);
DESCRIPTION
The sysconf() function provides a method for the application to determine the current value of a configurable system limit or option (variable) .
The name argument represents the system variable to be queried. The following table lists the minimal set of system variables from <limits.h>, <unistd.h> or <time.h> (for CLK_TCK) that can be returned by sysconf(), and the symbolic constants, defined in <unistd.h> that are the corresponding values used for name:
| Variable | Value of Name |
| ARG_MAX | _SC_ARG_MAX |
| BC_BASE_MAX | _SC_BC_BASE_MAX |
| BC_DIM_MAX | _SC_BC_DIM_MAX |
| BC_SCALE_MAX | _SC_BC_SCALE_MAX |
| BC_STRING_MAX | _SC_BC_STRING_MAX |
| CHILD_MAX | _SC_CHILD_MAX |
| CLK_TCK | _SC_CLK_TCK |
| COLL_WEIGHTS_MAX | _SC_COLL_WEIGHTS_MAX |
| EXPR_NEST_MAX | _SC_EXPR_NEST_MAX |
| LINE_MAX | _SC_LINE_MAX |
| NGROUPS_MAX | _SC_NGROUPS_MAX |
| OPEN_MAX | _SC_OPEN_MAX |
| PASS_MAX | _SC_PASS_MAX (LEGACY) |
| _POSIX2_C_BIND | _SC_2_C_BIND |
| _POSIX2_C_DEV | _SC_2_C_DEV |
| _POSIX2_C_VERSION | _SC_2_C_VERSION |
| _POSIX2_CHAR_TERM | _SC_2_CHAR_TERM |
| _POSIX2_FORT_DEV | _SC_2_FORT_DEV |
| _POSIX2_FORT_RUN | _SC_2_FORT_RUN |
| _POSIX2_LOCALEDEF | _SC_2_LOCALEDEF |
| _POSIX2_SW_DEV | _SC_2_SW_DEV |
| _POSIX2_UPE | _SC_2_UPE |
| _POSIX2_VERSION | _SC_2_VERSION |
| _POSIX_JOB_CONTROL | _SC_JOB_CONTROL |
| _POSIX_SAVED_IDS | _SC_SAVED_IDS |
| _POSIX_VERSION | _SC_VERSION |
| RE_DUP_MAX | _SC_RE_DUP_MAX |
| STREAM_MAX | _SC_STREAM_MAX |
| TZNAME_MAX | _SC_TZNAME_MAX |
| _XOPEN_CRYPT | _SC_XOPEN_CRYPT |
| _XOPEN_ENH_I18N | _SC_XOPEN_ENH_I18N |
| _XOPEN_SHM | _SC_XOPEN_SHM |
| _XOPEN_VERSION | _SC_XOPEN_VERSION |
| _XOPEN_XCU_VERSION | _SC_XOPEN_XCU_VERSION |
| _XOPEN_REALTIME | _SC_XOPEN_REALTIME |
| _XOPEN_REALTIME_THREADS | _SC_XOPEN_REALTIME_THREADS |
| _XOPEN_LEGACY | _SC_XOPEN_LEGACY |
| ATEXIT_MAX | _SC_ATEXIT_MAX |
| IOV_MAX | _SC_IOV_MAX |
| PAGESIZE | _SC_PAGESIZE |
| PAGE_SIZE | _SC_PAGE_SIZE |
| _XOPEN_UNIX | _SC_XOPEN_UNIX |
| _XBS5_ILP32_OFF32 | _SC_XBS5_ILP32_OFF32 |
| _XBS5_ILP32_OFFBIG | _SC_XBS5_ILP32_OFFBIG |
| _XBS5_LP64_OFF64 | _SC_XBS5_LP64_OFF64 |
| _XBS5_LPBIG_OFFBIG | _SC_XBS5_LPBIG_OFFBIG |
| AIO_LISTIO_MAX | _SC_AIO_LISTIO_MAX |
| AIO_MAX | _SC_AIO_MAX |
| AIO_PRIO_DELTA_MAX | _SC_AIO_PRIO_DELTA_MAX |
| DELAYTIMER_MAX | _SC_DELAYTIMER_MAX |
| MQ_OPEN_MAX | _SC_MQ_OPEN_MAX |
| MQ_PRIO_MAX | _SC_MQ_PRIO_MAX |
| RTSIG_MAX | _SC_RTSIG_MAX |
| SEM_NSEMS_MAX | _SC_SEM_NSEMS_MAX |
| SEM_VALUE_MAX | _SC_SEM_VALUE_MAX |
| SIGQUEUE_MAX | _SC_SIGQUEUE_MAX |
| TIMER_MAX | _SC_TIMER_MAX |
| _POSIX_ASYNCHRONOUS_IO | _SC_ASYNCHRONOUS_IO |
| _POSIX_FSYNC | _SC_FSYNC |
| _POSIX_MAPPED_FILES | _SC_MAPPED_FILES |
| _POSIX_MEMLOCK | _SC_MEMLOCK |
| _POSIX_MEMLOCK_RANGE | _SC_MEMLOCK_RANGE |
| _POSIX_MEMORY_PROTECTION | _SC_MEMORY_PROTECTION |
| _POSIX_MESSAGE_PASSING | _SC_MESSAGE_PASSING |
| _POSIX_PRIORITIZED_IO | _SC_PRIORITIZED_IO |
| _POSIX_PRIORITY_SCHEDULING | _SC_PRIORITY_SCHEDULING |
| _POSIX_REALTIME_SIGNALS | _SC_REALTIME_SIGNALS |
| _POSIX_SEMAPHORES | _SC_SEMAPHORES |
| _POSIX_SHARED_MEMORY_OBJECTS | _SC_SHARED_MEMORY_OBJECTS |
| _POSIX_SYNCHRONIZED_IO | _SC_SYNCHRONIZED_IO |
| _POSIX_TIMERS | _SC_TIMERS |
| Maximum size of and data buffers | _SC_GETGR_R_SIZE_MAX |
| Maximum size of and data buffers | _SC_GETPW_R_SIZE_MAX |
| LOGIN_NAME_MAX | _SC_LOGIN_NAME_MAX |
| PTHREAD_DESTRUCTOR_ITERATIONS | _SC_THREAD_DESTRUCTOR_ITERATIONS |
| PTHREAD_KEYS_MAX | _SC_THREAD_KEYS_MAX |
| PTHREAD_STACK_MIN | _SC_THREAD_STACK_MIN |
| PTHREAD_THREADS_MAX | _SC_THREAD_THREADS_MAX |
| TTY_NAME_MAX | _SC_TTY_NAME_MAX |
| _POSIX_THREADS | _SC_THREADS |
| _POSIX_THREAD_ATTR_STACKADDR | _SC_THREAD_ATTR_STACKADDR |
| _POSIX_THREAD_ATTR_STACKSIZE | _SC_THREAD_ATTR_STACKSIZE |
| _POSIX_THREAD_PRIORITY_SCHEDULING | _SC_THREAD_PRIORITY_SCHEDULING |
| _POSIX_THREAD_PRIO_INHERIT | _SC_THREAD_PRIO_INHERIT |
| _POSIX_THREAD_PRIO_PROTECT | _SC_THREAD_PRIO_PROTECT |
| _POSIX_THREAD_PROCESS_SHARED | _SC_THREAD_PROCESS_SHARED |
| _POSIX_THREAD_SAFE_FUNCTIONS | _SC_THREAD_SAFE_FUNCTIONS |
RETURN VALUE
If name is an invalid value, sysconf() returns -1 and sets errno to indicate the error. If the variable corresponding to name is associated with functionality that is not supported by the system, sysconf() returns -1 without changing the value of errno .
Otherwise, sysconf() returns the current variable value on the system. The value returned will not be more restrictive than the corresponding value described to the application when it was compiled with the implementation's <limits.h>, <unistd.h> or <time.h>. The value will not change during the lifetime of the calling process.
ERRORS
The sysconf() function will fail if:
- [EINVAL]
- The value of the name argument is invalid.
EXAMPLES
None.
APPLICATION USAGE
As -1 is a permissible return value in a successful situation, an application wishing to check for error situations should set errno to 0, then call sysconf() , and, if it returns -1, check to see if errno is non-zero.
If the value of:
sysconf(_SC_2_VERSION) is not equal to the value of
the {_POSIX2_VERSION} symbolic constant, the utilities available via
system() or
popen()
might not behave as described in the XCU specification.
This would mean that the application is not running in an environment that
conforms to the XCU specification. Some applications might
be able to deal with this, others might not. However, the interfaces defined
in this specification will continue to operate as specified, even if:
sysconf(_SC_2_VERSION) reports that the utilities no
longer perform as specified.
FUTURE DIRECTIONS
None.
SEE ALSO
confstr(3) , pathconf(3) , <limits.h> , <time.h> , <unistd.h> , the XCU specification of getconf .
DERIVATION
Derived from the POSIX.1-1988 standard.