1SYSCONF(3) Linux Programmer's Manual SYSCONF(3)
2
3
4
6 sysconf - Get configuration information at runtime
7
9 #include <unistd.h>
10
11 long sysconf(int name);
12
14 POSIX allows an application to test at compile or run time whether cer‐
15 tain options are supported, or what the value is of certain config‐
16 urable constants or limits.
17
18 At compile time this is done by including <unistd.h> and/or <limits.h>
19 and testing the value of certain macros.
20
21 At run time, one can ask for numerical values using the present func‐
22 tion sysconf(). One can ask for numerical values that may depend on
23 the file system a file is in using the calls fpathconf(3) and path‐
24 conf(3). One can ask for string values using confstr(3).
25
26 The values obtained from these functions are system configuration con‐
27 stants. They do not change during the lifetime of a process.
28
29 For options, typically, there is a constant _POSIX_FOO that may be
30 defined in <unistd.h>. If it is undefined, one should ask at run time.
31 If it is defined to -1, then the option is not supported. If it is
32 defined to 0, then relevant functions and headers exist, but one has to
33 ask at runtime what degree of support is available. If it is defined
34 to a value other than -1 or 0, then the option is supported. Usually
35 the value (such as 200112L) indicates the year and month of the POSIX
36 revision describing the option. Glibc uses the value 1 to indicate
37 support as long as the POSIX revision has not been published yet. The
38 sysconf() argument will be _SC_FOO. For a list of options, see
39 posixoptions(7).
40
41 For variables or limits, typically, there is a constant _FOO, maybe
42 defined in <limits.h>, or _POSIX_FOO, maybe defined in <unistd.h>. The
43 constant will not be defined if the limit is unspecified. If the con‐
44 stant is defined, it gives a guaranteed value, and a greater value
45 might actually be supported. If an application wants to take advantage
46 of values which may change between systems, a call to sysconf() can be
47 made. The sysconf() argument will be _SC_FOO.
48
49 POSIX.1 Variables
50 We give the name of the variable, the name of the sysconf() argument
51 used to inquire about its value, and a short description.
52
53 First, the POSIX.1 compatible values.
54
55 ARG_MAX - _SC_ARG_MAX
56 The maximum length of the arguments to the exec(3) family of
57 functions. Must not be less than _POSIX_ARG_MAX (4096).
58
59 CHILD_MAX - _SC_CHILD_MAX
60 The max number of simultaneous processes per user ID. Must not
61 be less than _POSIX_CHILD_MAX (25).
62
63 HOST_NAME_MAX - _SC_HOST_NAME_MAX
64 Max length of a hostname, not including the terminating null
65 byte, as returned by gethostname(2). Must not be less than
66 _POSIX_HOST_NAME_MAX (255).
67
68 LOGIN_NAME_MAX - _SC_LOGIN_NAME_MAX
69 Maximum length of a login name, including the terminating null
70 byte. Must not be less than _POSIX_LOGIN_NAME_MAX (9).
71
72 clock ticks - _SC_CLK_TCK
73 The number of clock ticks per second. The corresponding vari‐
74 able is obsolete. It was of course called CLK_TCK. (Note: the
75 macro CLOCKS_PER_SEC does not give information: it must equal
76 1000000.)
77
78 OPEN_MAX - _SC_OPEN_MAX
79 The maximum number of files that a process can have open at any
80 time. Must not be less than _POSIX_OPEN_MAX (20).
81
82 PAGESIZE - _SC_PAGESIZE
83 Size of a page in bytes. Must not be less than 1. (Some sys‐
84 tems use PAGE_SIZE instead.)
85
86 RE_DUP_MAX - _SC_RE_DUP_MAX
87 The number of repeated occurrences of a BRE permitted by
88 regexec(3) and regcomp(3). Must not be less than
89 _POSIX2_RE_DUP_MAX (255).
90
91 STREAM_MAX - _SC_STREAM_MAX
92 The maximum number of streams that a process can have open at
93 any time. If defined, it has the same value as the standard C
94 macro FOPEN_MAX. Must not be less than _POSIX_STREAM_MAX (8).
95
96 SYMLOOP_MAX
97 The maximum number of symbolic links seen in a pathname before
98 resolution returns ELOOP. Must not be less than _POSIX_SYM‐
99 LOOP_MAX (8).
100
101 TTY_NAME_MAX - _SC_TTY_NAME_MAX
102 The maximum length of terminal device name, including the termi‐
103 nating null byte. Must not be less than _POSIX_TTY_NAME_MAX
104 (9).
105
106 TZNAME_MAX - _SC_TZNAME_MAX
107 The maximum number of bytes in a timezone name. Must not be
108 less than _POSIX_TZNAME_MAX (6).
109
110 _POSIX_VERSION - _SC_VERSION
111 indicates the year and month the POSIX.1 standard was approved
112 in the format YYYYMML; the value 199009L indicates the Sept.
113 1990 revision.
114
115 POSIX.2 Variables
116 Next, the POSIX.2 values, giving limits for utilities.
117
118 BC_BASE_MAX - _SC_BC_BASE_MAX
119 indicates the maximum obase value accepted by the bc(1) utility.
120
121 BC_DIM_MAX - _SC_BC_DIM_MAX
122 indicates the maximum value of elements permitted in an array by
123 bc(1).
124
125 BC_SCALE_MAX - _SC_BC_SCALE_MAX
126 indicates the maximum scale value allowed by bc(1).
127
128 BC_STRING_MAX - _SC_BC_STRING_MAX
129 indicates the maximum length of a string accepted by bc(1).
130
131 COLL_WEIGHTS_MAX - _SC_COLL_WEIGHTS_MAX
132 indicates the maximum numbers of weights that can be assigned to
133 an entry of the LC_COLLATE order keyword in the locale defini‐
134 tion file,
135
136 EXPR_NEST_MAX - _SC_EXPR_NEST_MAX
137 is the maximum number of expressions which can be nested within
138 parentheses by expr(1).
139
140 LINE_MAX - _SC_LINE_MAX
141 The maximum length of a utility's input line length, either from
142 standard input or from a file. This includes length for a
143 trailing newline.
144
145 RE_DUP_MAX - _SC_RE_DUP_MAX
146 The maximum number of repeated occurrences of a regular expres‐
147 sion when the interval notation \{m,n\} is used.
148
149 POSIX2_VERSION - _SC_2_VERSION
150 indicates the version of the POSIX.2 standard in the format of
151 YYYYMML.
152
153 POSIX2_C_DEV - _SC_2_C_DEV
154 indicates whether the POSIX.2 C language development facilities
155 are supported.
156
157 POSIX2_FORT_DEV - _SC_2_FORT_DEV
158 indicates whether the POSIX.2 FORTRAN development utilities are
159 supported.
160
161 POSIX2_FORT_RUN - _SC_2_FORT_RUN
162 indicates whether the POSIX.2 FORTRAN runtime utilities are sup‐
163 ported.
164
165 _POSIX2_LOCALEDEF - _SC_2_LOCALEDEF
166 indicates whether the POSIX.2 creation of locates via
167 localedef(1) is supported.
168
169 POSIX2_SW_DEV - _SC_2_SW_DEV
170 indicates whether the POSIX.2 software development utilities
171 option is supported.
172
173 These values also exist, but may not be standard.
174
175 - _SC_PHYS_PAGES
176 The number of pages of physical memory. Note that it is possi‐
177 ble for the product of this value and the value of _SC_PAGE_SIZE
178 to overflow.
179
180 - _SC_AVPHYS_PAGES
181 The number of currently available pages of physical memory.
182
183 - _SC_NPROCESSORS_CONF
184 The number of processors configured.
185
186 - _SC_NPROCESSORS_ONLN
187 The number of processors currently online (available).
188
190 If name is invalid, -1 is returned, and errno is set to EINVAL. Other‐
191 wise, the value returned is the value of the system resource and errno
192 is not changed. In the case of options, a positive value is returned
193 if a queried option is available, and -1 if it is not. In the case of
194 limits, -1 means that there is no definite limit.
195
197 POSIX.1-2001.
198
200 It is difficult to use ARG_MAX because it is not specified how much of
201 the argument space for exec(3) is consumed by the user's environment
202 variables.
203
204 Some returned values may be huge; they are not suitable for allocating
205 memory.
206
208 bc(1), expr(1), getconf(1), locale(1), fpathconf(3), pathconf(3),
209 posixoptions(7)
210
212 This page is part of release 3.25 of the Linux man-pages project. A
213 description of the project, and information about reporting bugs, can
214 be found at http://www.kernel.org/doc/man-pages/.
215
216
217
218GNU 2007-12-12 SYSCONF(3)