The Open Group Base Specifications Issue 6
IEEE Std 1003.1-2001
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.

NAME

sysconf - get configurable system variables

SYNOPSIS

#include <unistd.h>

long 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). Support for some system variables is dependent on implementation options (as indicated by the margin codes in the following table). Where an implementation option is not supported, the variable need not be supported.

The name argument represents the system variable to be queried. The following table lists the minimal set of system variables from <limits.h> or <unistd.h> that can be returned by sysconf(), and the symbolic constants defined in <unistd.h> that are the corresponding values used for name. Support for some configuration variables is dependent on implementation options (see shading and margin codes in the table below). Where an implementation option is not supported, the variable need not be supported.

Variable

Value of Name

[AIO] [Option Start] {AIO_LISTIO_MAX}

_SC_AIO_LISTIO_MAX

{AIO_MAX}

_SC_AIO_MAX

{AIO_PRIO_DELTA_MAX}

_SC_AIO_PRIO_DELTA_MAX [Option End]

{ARG_MAX}

_SC_ARG_MAX

[XSI] [Option Start] {ATEXIT_MAX}

_SC_ATEXIT_MAX [Option End]

{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

Clock ticks/second

_SC_CLK_TCK

{COLL_WEIGHTS_MAX}

_SC_COLL_WEIGHTS_MAX

[XSI] [Option Start] {DELAYTIMER_MAX}

_SC_DELAYTIMER_MAX [Option End]

{EXPR_NEST_MAX}

_SC_EXPR_NEST_MAX

{HOST_NAME_MAX}

_SC_HOST_NAME_MAX

[XSI] [Option Start] {IOV_MAX}

_SC_IOV_MAX [Option End]

{LINE_MAX}

_SC_LINE_MAX

{LOGIN_NAME_MAX}

_SC_LOGIN_NAME_MAX

{NGROUPS_MAX}

_SC_NGROUPS_MAX

[TSF] [Option Start] Maximum size of getgrgid_r() and

_SC_GETGR_R_SIZE_MAX

getgrnam_r() data buffers

 

Maximum size of getpwuid_r() and

_SC_GETPW_R_SIZE_MAX

getpwnam_r() data buffers

 

[MSG] [Option Start] {MQ_OPEN_MAX}

_SC_MQ_OPEN_MAX

{MQ_PRIO_MAX}

_SC_MQ_PRIO_MAX [Option End]


Variable

Value of Name

{OPEN_MAX}

_SC_OPEN_MAX

[ADV] [Option Start] _POSIX_ADVISORY_INFO

_SC_ADVISORY_INFO

[BAR] [Option Start] _POSIX_BARRIERS

_SC_BARRIERS

[AIO] [Option Start] _POSIX_ASYNCHRONOUS_IO

_SC_ASYNCHRONOUS_IO

[CS] [Option Start] _POSIX_CLOCK_SELECTION

_SC_CLOCK_SELECTION

[CPT] [Option Start] _POSIX_CPUTIME

_SC_CPUTIME [Option End]

_POSIX_FILE_LOCKING

_SC_FILE_LOCKING

[FSC] [Option Start] _POSIX_FSYNC

_SC_FSYNC [Option End]

_POSIX_JOB_CONTROL

_SC_JOB_CONTROL

[MF] [Option Start] _POSIX_MAPPED_FILES

_SC_MAPPED_FILES

[ML] [Option Start] _POSIX_MEMLOCK

_SC_MEMLOCK

[MR] [Option Start] _POSIX_MEMLOCK_RANGE

_SC_MEMLOCK_RANGE

[MPR] [Option Start] _POSIX_MEMORY_PROTECTION

_SC_MEMORY_PROTECTION

[MSG] [Option Start] _POSIX_MESSAGE_PASSING

_SC_MESSAGE_PASSING

[MON] [Option Start] _POSIX_MONOTONIC_CLOCK

_SC_MONOTONIC_CLOCK [Option End]

_POSIX_MULTI_PROCESS

_SC_MULTI_PROCESS

[PIO] [Option Start] _POSIX_PRIORITIZED_IO

_SC_PRIORITIZED_IO

[PS] [Option Start] _POSIX_PRIORITY_SCHEDULING

_SC_PRIORITY_SCHEDULING

[THR] [Option Start] _POSIX_READER_WRITER_LOCKS

_SC_READER_WRITER_LOCKS

[RTS] [Option Start] _POSIX_REALTIME_SIGNALS

_SC_REALTIME_SIGNALS [Option End]

_POSIX_REGEXP

_SC_REGEXP

_POSIX_SAVED_IDS

_SC_SAVED_IDS

[SEM] [Option Start] _POSIX_SEMAPHORES

_SC_SEMAPHORES

[SHM] [Option Start] _POSIX_SHARED_MEMORY_OBJECTS

_SC_SHARED_MEMORY_OBJECTS [Option End]

_POSIX_SHELL

_SC_SHELL

[SPN] [Option Start] _POSIX_SPAWN

_SC_SPAWN

[SPI] [Option Start] _POSIX_SPIN_LOCKS

_SC_SPIN_LOCKS

[SS] [Option Start] _POSIX_SPORADIC_SERVER

_SC_SPORADIC_SERVER

[SIO] [Option Start] _POSIX_SYNCHRONIZED_IO

_SC_SYNCHRONIZED_IO

[TSA] [Option Start] _POSIX_THREAD_ATTR_STACKADDR

_SC_THREAD_ATTR_STACKADDR

[TSS] [Option Start] _POSIX_THREAD_ATTR_STACKSIZE

_SC_THREAD_ATTR_STACKSIZE

[TCT] [Option Start] _POSIX_THREAD_CPUTIME

_SC_THREAD_CPUTIME

[TPI] [Option Start] _POSIX_THREAD_PRIO_INHERIT

_SC_THREAD_PRIO_INHERIT

[TPP] [Option Start] _POSIX_THREAD_PRIO_PROTECT

_SC_THREAD_PRIO_PROTECT

[TPS] [Option Start] _POSIX_THREAD_PRIORITY_SCHEDULING

_SC_THREAD_PRIORITY_SCHEDULING

[TSH] [Option Start] _POSIX_THREAD_PROCESS_SHARED

_SC_THREAD_PROCESS_SHARED

[TSF] [Option Start] _POSIX_THREAD_SAFE_FUNCTIONS

_SC_THREAD_SAFE_FUNCTIONS

[TSP] [Option Start] _POSIX_THREAD_SPORADIC_SERVER

_SC_THREAD_SPORADIC_SERVER

[THR] [Option Start] _POSIX_THREADS

_SC_THREADS

[TMO] [Option Start] _POSIX_TIMEOUTS

_SC_TIMEOUTS

[TMR] [Option Start] _POSIX_TIMERS

_SC_TIMERS

[TRC] [Option Start] _POSIX_TRACE

_SC_TRACE

[TEF] [Option Start] _POSIX_TRACE_EVENT_FILTER

_SC_TRACE_EVENT_FILTER

[TRI] [Option Start] _POSIX_TRACE_INHERIT

_SC_TRACE_INHERIT

[TRL] [Option Start] _POSIX_TRACE_LOG

_SC_TRACE_LOG

[TYM] [Option Start] _POSIX_TYPED_MEMORY_OBJECTS

_SC_TYPED_MEMORY_OBJECTS [Option End]


Variable

Value of Name

_POSIX_VERSION

_SC_VERSION

_POSIX_V6_ILP32_OFF32

_SC_V6_ILP32_OFF32

_POSIX_V6_ILP32_OFFBIG

_SC_V6_ILP32_OFFBIG

_POSIX_V6_LP64_OFF64

_SC_V6_LP64_OFF64

_POSIX_V6_LPBIG_OFFBIG

_SC_V6_LPBIG_OFFBIG

_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

[BE] [Option Start] _POSIX2_PBS

_SC_2_PBS

_POSIX2_PBS_ACCOUNTING

_SC_2_PBS_ACCOUNTING

_POSIX2_PBS_LOCATE

_SC_2_PBS_LOCATE

_POSIX2_PBS_MESSAGE

_SC_2_PBS_MESSAGE

_POSIX2_PBS_TRACK

_SC_2_PBS_TRACK [Option End]

_POSIX2_SW_DEV

_SC_2_SW_DEV

_POSIX2_UPE

_SC_2_UPE

_POSIX2_VERSION

_SC_2_VERSION

_REGEX_VERSION

_SC_REGEX_VERSION

[XSI] [Option Start] {PAGE_SIZE}

_SC_PAGE_SIZE [Option End]

{PAGESIZE}

_SC_PAGESIZE

[THR] [Option Start] {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 [Option End]

{RE_DUP_MAX}

_SC_RE_DUP_MAX

[RTS] [Option Start] {RTSIG_MAX}

_SC_RTSIG_MAX

[SEM] [Option Start] {SEM_NSEMS_MAX}

_SC_SEM_NSEMS_MAX

{SEM_VALUE_MAX}

_SC_SEM_VALUE_MAX

[RTS] [Option Start] {SIGQUEUE_MAX}

_SC_SIGQUEUE_MAX [Option End]

{STREAM_MAX}

_SC_STREAM_MAX

{SYMLOOP_MAX}

_SC_SYMLOOP_MAX

[TMR] [Option Start] {TIMER_MAX}

_SC_TIMER_MAX [Option End]

{TTY_NAME_MAX}

_SC_TTY_NAME_MAX

{TZNAME_MAX}

_SC_TZNAME_MAX

[XSI] [Option Start] _XBS5_ILP32_OFF32 (LEGACY)

_SC_XBS5_ILP32_OFF32 (LEGACY)

_XBS5_ILP32_OFFBIG (LEGACY)

_SC_XBS5_ILP32_OFFBIG (LEGACY)

_XBS5_LP64_OFF64 (LEGACY)

_SC_XBS5_LP64_OFF64 (LEGACY)

_XBS5_LPBIG_OFFBIG (LEGACY)

_SC_XBS5_LPBIG_OFFBIG (LEGACY)

_XOPEN_CRYPT

_SC_XOPEN_CRYPT

_XOPEN_ENH_I18N

_SC_XOPEN_ENH_I18N [Option End]


Variable

Value of Name

[XSI] [Option Start] _XOPEN_LEGACY

_SC_XOPEN_LEGACY

_XOPEN_REALTIME

_SC_XOPEN_REALTIME

_XOPEN_REALTIME_THREADS

_SC_XOPEN_REALTIME_THREADS

_XOPEN_SHM

_SC_XOPEN_SHM

_XOPEN_UNIX

_SC_XOPEN_UNIX

_XOPEN_VERSION

_SC_XOPEN_VERSION

_XOPEN_XCU_VERSION

_SC_XOPEN_XCU_VERSION [Option End]

RETURN VALUE

If name is an invalid value, sysconf() shall return -1 and set errno to indicate the error. If the variable corresponding to name has no limit, sysconf() shall return -1 without changing the value of errno. Note that indefinite limits do not imply infinite limits; see <limits.h>.

Otherwise, sysconf() shall return the current variable value on the system. The value returned shall not be more restrictive than the corresponding value described to the application when it was compiled with the implementation's <limits.h> or <unistd.h>. The value shall not change during the lifetime of the calling process.

ERRORS

The sysconf() function shall fail if:

[EINVAL]
The value of the name argument is invalid.

The following sections are informative.

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 Shell and Utilities volume of IEEE Std 1003.1-2001. This would mean that the application is not running in an environment that conforms to the Shell and Utilities volume of IEEE Std 1003.1-2001. Some applications might be able to deal with this, others might not. However, the functions defined in this volume of IEEE Std 1003.1-2001 continue to operate as specified, even if sysconf(_SC_2_VERSION) reports that the utilities no longer perform as specified.

RATIONALE

This functionality was added in response to requirements of application developers and of system vendors who deal with many international system configurations. It is closely related to pathconf() and fpathconf().

Although a conforming application can run on all systems by never demanding more resources than the minimum values published in this volume of IEEE Std 1003.1-2001, it is useful for that application to be able to use the actual value for the quantity of a resource available on any given system. To do this, the application makes use of the value of a symbolic constant in <limits.h> or <unistd.h>.

However, once compiled, the application must still be able to cope if the amount of resource available is increased. To that end, an application may need a means of determining the quantity of a resource, or the presence of an option, at execution time.

Two examples are offered:

  1. Applications may wish to act differently on systems with or without job control. Applications vendors who wish to distribute only a single binary package to all instances of a computer architecture would be forced to assume job control is never available if it were to rely solely on the <unistd.h> value published in this volume of IEEE Std 1003.1-2001.

  2. International applications vendors occasionally require knowledge of the number of clock ticks per second. Without these facilities, they would be required to either distribute their applications partially in source form or to have 50 Hz and 60 Hz versions for the various countries in which they operate.

It is the knowledge that many applications are actually distributed widely in executable form that leads to this facility. If limited to the most restrictive values in the headers, such applications would have to be prepared to accept the most limited environments offered by the smallest microcomputers. Although this is entirely portable, there was a consensus that they should be able to take advantage of the facilities offered by large systems, without the restrictions associated with source and object distributions.

During the discussions of this feature, it was pointed out that it is almost always possible for an application to discern what a value might be at runtime by suitably testing the various functions themselves. And, in any event, it could always be written to adequately deal with error returns from the various functions. In the end, it was felt that this imposed an unreasonable level of complication and sophistication on the application writer.

This runtime facility is not meant to provide ever-changing values that applications have to check multiple times. The values are seen as changing no more frequently than once per system initialization, such as by a system administrator or operator with an automatic configuration program. This volume of IEEE Std 1003.1-2001 specifies that they shall not change within the lifetime of the process.

Some values apply to the system overall and others vary at the file system or directory level. The latter are described in pathconf() .

Note that all values returned must be expressible as integers. String values were considered, but the additional flexibility of this approach was rejected due to its added complexity of implementation and use.

Some values, such as {PATH_MAX}, are sometimes so large that they must not be used to, say, allocate arrays. The sysconf() function returns a negative value to show that this symbolic constant is not even defined in this case.

Similar to pathconf(), this permits the implementation not to have a limit. When one resource is infinite, returning an error indicating that some other resource limit has been reached is conforming behavior.

FUTURE DIRECTIONS

None.

SEE ALSO

confstr() , pathconf() , the Base Definitions volume of IEEE Std 1003.1-2001, <limits.h>, <unistd.h>, the Shell and Utilities volume of IEEE Std 1003.1-2001, getconf

CHANGE HISTORY

First released in Issue 3. Included for alignment with the POSIX.1-1988 standard.

Issue 5

The DESCRIPTION is updated for alignment with the POSIX Realtime Extension and the POSIX Threads Extension.

The _XBS_ variables and name values are added to the table of system variables in the DESCRIPTION. These are all marked EX.

Issue 6

The symbol CLK_TCK is obsolescent and removed. It is replaced with the phrase "clock ticks per second".

The symbol {PASS_MAX} is removed.

The following changes were made to align with the IEEE P1003.1a draft standard:

The following sysconf() variables and their associated names are added for alignment with IEEE Std 1003.1d-1999:

_POSIX_ADVISORY_INFO
_POSIX_CPUTIME
_POSIX_SPAWN
_POSIX_SPORADIC_SERVER
_POSIX_THREAD_CPUTIME
_POSIX_THREAD_SPORADIC_SERVER
_POSIX_TIMEOUTS

The following changes are made to the DESCRIPTION for alignment with IEEE Std 1003.1j-2000:

The following system variables are added for alignment with IEEE Std 1003.2d-1994:

_POSIX2_PBS
_POSIX2_PBS_ACCOUNTING
_POSIX2_PBS_LOCATE
_POSIX2_PBS_MESSAGE
_POSIX2_PBS_TRACK

The following sysconf() variables and their associated names are added for alignment with IEEE Std 1003.1q-2000:

_POSIX_TRACE
_POSIX_TRACE_EVENT_FILTER
_POSIX_TRACE_INHERIT
_POSIX_TRACE_LOG

The macros associated with the c89 programming models are marked LEGACY, and new equivalent macros associated with c99 are introduced.

End of informative text.


UNIX ® is a registered Trademark of The Open Group.
POSIX ® is a registered Trademark of The IEEE.
[ Main Index | XBD | XCU | XSH | XRAT ]