COHERENT manpages
This page displays the COHERENT manpage for sysconf() [Get configurable system variables].
List of available manpages
Index
sysconf() -- System Call (libc) Get configurable system variables #include <unistd.h> long sysconf(name) int name; sysconf() returns the value of the system limit or option identified by name. In the following table, the left column gives a symbolic constant to which name can be set, and the right column gives the corresponding system variable (as defined in <limits.h> and <unistd.h>) that sysconf() reads and returns: Name Variable _SC_ARG_MAX ARG_MAX _SC_CHILD_MAX CHILD_MAX _SC_CLK_TCK CLK_TCK _SC_NGROUPS_MAX NGROUPS_MAX _SC_OPEN_MAX OPEN_MAX _SC_PASS_MAX PASS_MAX _SC_JOB_CONTROL _POSIX_JOB_CONTROL _SC_SAVED_IDS _POSIX_SAVED_IDS _SC_VERSION _POSIX_VERSION The following describes the values returned in more detail: ARG_MAX Maximum number of bytes that can be occupied by a process's argument list and environment. CHILD_MAX Number of processes a user can run simultaneously. CLK_TCK Length of a clock tick, in microseconds. NGROUPS_MAX The maximum number of groups to which a user can belong, in addition to her primary group. OPEN_MAX The number of files a process can have open simultaneously. PASS_MAX The maximum length of a password. Please note that the constant _SC_PASS_MAX is defined only for programs compiled for UNIX System V release 4. _POSIX_JOB_CONTROL This is a Boolean flag that indicates whether the operating system supports the POSIX job-control functions. _POSIX_SAVED_IDS This is a Boolean flag that indicates whether the operating system permits each process to have a saved set-user ID and a saved set-group ID. _POSIX_VERSION This is a long integer that encodes the four-digit year and two-digit month of approval for the version of the POSIX standard supported by the operating system. For example, 199009L indicates the version approved in September of 1990. The value of variable CLK_TCK can vary; you should not assume that it is a compile-time constant. If name is an invalid value, sysconf() returns -1 and set errno to an appropriate value. If sysconf() fails due to a value of name that is not defined on the system, it returns -1 without setting errno. Example At the time of this writing (August 1994), the program #include <unistd.h> main() { printf("_SC_ARG_MAX: %d\n", sysconf(_SC_ARG_MAX)); printf("_SC_CHILD_MAX: %d\n", sysconf(_SC_CHILD_MAX)); printf("_SC_CLK_TCK: %d\n", sysconf(_SC_CLK_TCK)); printf("_SC_NGROUPS_MAX: %d\n", sysconf(_SC_NGROUPS_MAX)); printf("_SC_OPEN_MAX: %d\n", sysconf(_SC_OPEN_MAX)); printf("_SC_JOB_CONTROL: %d\n", sysconf(_SC_JOB_CONTROL)); printf("_SC_SAVED_IDS: %d\n", sysconf(_SC_SAVED_IDS)); printf("_SC_VERSION: %d\n", sysconf(_SC_VERSION)); } returns the following values: _SC_ARG_MAX: 5120 _SC_CHILD_MAX: 25 _SC_CLK_TCK: 100 _SC_NGROUPS_MAX: 32 _SC_OPEN_MAX: 60 _SC_JOB_CONTROL: 0 _SC_SAVED_IDS: 1 _SC_VERSION: 199009 See Also libc, unistd.h POSIX Standard, §4.8.1 Notes Programs can use the appropriate #ifndef guards to control whether they use sysconf() or a symbol from <limits.h> for each kind of limit. For example: #include <unistd.h> #include <limits.h> #ifdef _SC_OPEN_MAX max = sysconf (_SC_OPEN_MAX); #elif defined (OPEN_MAX) max = OPEN_MAX; #else /* either complain, or make some rational assumption, e.g. */ #error Open file descriptor limits cannot be determined #endif