1SYSCONF(3) Linux Programmer's Manual SYSCONF(3)
2
3
4
6 sysconf - get configuration information at run time
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 filesystem in which a file resides using 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 run time 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 maximum number of simultaneous processes per user ID. Must
61 not be less than _POSIX_CHILD_MAX (25).
62
63 HOST_NAME_MAX - _SC_HOST_NAME_MAX
64 Maximum 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 NGROUPS_MAX - _SC_NGROUPS_MAX
73 Maximum number of supplementary group IDs.
74
75 clock ticks - _SC_CLK_TCK
76 The number of clock ticks per second. The corresponding vari‐
77 able is obsolete. It was of course called CLK_TCK. (Note: the
78 macro CLOCKS_PER_SEC does not give information: it must equal
79 1000000.)
80
81 OPEN_MAX - _SC_OPEN_MAX
82 The maximum number of files that a process can have open at any
83 time. Must not be less than _POSIX_OPEN_MAX (20).
84
85 PAGESIZE - _SC_PAGESIZE
86 Size of a page in bytes. Must not be less than 1. (Some sys‐
87 tems use PAGE_SIZE instead.)
88
89 RE_DUP_MAX - _SC_RE_DUP_MAX
90 The number of repeated occurrences of a BRE permitted by
91 regexec(3) and regcomp(3). Must not be less than
92 _POSIX2_RE_DUP_MAX (255).
93
94 STREAM_MAX - _SC_STREAM_MAX
95 The maximum number of streams that a process can have open at
96 any time. If defined, it has the same value as the standard C
97 macro FOPEN_MAX. Must not be less than _POSIX_STREAM_MAX (8).
98
99 SYMLOOP_MAX - _SC_SYMLOOP_MAX
100 The maximum number of symbolic links seen in a pathname before
101 resolution returns ELOOP. Must not be less than _POSIX_SYM‐
102 LOOP_MAX (8).
103
104 TTY_NAME_MAX - _SC_TTY_NAME_MAX
105 The maximum length of terminal device name, including the termi‐
106 nating null byte. Must not be less than _POSIX_TTY_NAME_MAX
107 (9).
108
109 TZNAME_MAX - _SC_TZNAME_MAX
110 The maximum number of bytes in a timezone name. Must not be
111 less than _POSIX_TZNAME_MAX (6).
112
113 _POSIX_VERSION - _SC_VERSION
114 indicates the year and month the POSIX.1 standard was approved
115 in the format YYYYMML; the value 199009L indicates the Sept.
116 1990 revision.
117
118 POSIX.2 variables
119 Next, the POSIX.2 values, giving limits for utilities.
120
121 BC_BASE_MAX - _SC_BC_BASE_MAX
122 indicates the maximum obase value accepted by the bc(1) utility.
123
124 BC_DIM_MAX - _SC_BC_DIM_MAX
125 indicates the maximum value of elements permitted in an array by
126 bc(1).
127
128 BC_SCALE_MAX - _SC_BC_SCALE_MAX
129 indicates the maximum scale value allowed by bc(1).
130
131 BC_STRING_MAX - _SC_BC_STRING_MAX
132 indicates the maximum length of a string accepted by bc(1).
133
134 COLL_WEIGHTS_MAX - _SC_COLL_WEIGHTS_MAX
135 indicates the maximum numbers of weights that can be assigned to
136 an entry of the LC_COLLATE order keyword in the locale defini‐
137 tion file,
138
139 EXPR_NEST_MAX - _SC_EXPR_NEST_MAX
140 is the maximum number of expressions which can be nested within
141 parentheses by expr(1).
142
143 LINE_MAX - _SC_LINE_MAX
144 The maximum length of a utility's input line, either from stan‐
145 dard input or from a file. This includes space for a trailing
146 newline.
147
148 RE_DUP_MAX - _SC_RE_DUP_MAX
149 The maximum number of repeated occurrences of a regular expres‐
150 sion when the interval notation \{m,n\} is used.
151
152 POSIX2_VERSION - _SC_2_VERSION
153 indicates the version of the POSIX.2 standard in the format of
154 YYYYMML.
155
156 POSIX2_C_DEV - _SC_2_C_DEV
157 indicates whether the POSIX.2 C language development facilities
158 are supported.
159
160 POSIX2_FORT_DEV - _SC_2_FORT_DEV
161 indicates whether the POSIX.2 FORTRAN development utilities are
162 supported.
163
164 POSIX2_FORT_RUN - _SC_2_FORT_RUN
165 indicates whether the POSIX.2 FORTRAN run-time utilities are
166 supported.
167
168 _POSIX2_LOCALEDEF - _SC_2_LOCALEDEF
169 indicates whether the POSIX.2 creation of locates via
170 localedef(1) is supported.
171
172 POSIX2_SW_DEV - _SC_2_SW_DEV
173 indicates whether the POSIX.2 software development utilities
174 option is supported.
175
176 These values also exist, but may not be standard.
177
178 - _SC_PHYS_PAGES
179 The number of pages of physical memory. Note that it is possi‐
180 ble for the product of this value and the value of _SC_PAGESIZE
181 to overflow.
182
183 - _SC_AVPHYS_PAGES
184 The number of currently available pages of physical memory.
185
186 - _SC_NPROCESSORS_CONF
187 The number of processors configured. See also
188 get_nprocs_conf(3).
189
190 - _SC_NPROCESSORS_ONLN
191 The number of processors currently online (available). See also
192 get_nprocs_conf(3).
193
195 The return value of sysconf() is one of the following:
196
197 * On error, -1 is returned and errno is set to indicate the cause of
198 the error (for example, EINVAL, indicating that name is invalid).
199
200 * If name corresponds to a maximum or minimum limit, and that limit is
201 indeterminate, -1 is returned and errno is not changed. (To distin‐
202 guish an indeterminate limit from an error, set errno to zero before
203 the call, and then check whether errno is nonzero when -1 is
204 returned.)
205
206 * If name corresponds to an option, a positive value is returned if
207 the option is supported, and -1 is returned if the option is not
208 supported.
209
210 * Otherwise, the current value of the option or limit is returned.
211 This value will not be more restrictive than the corresponding value
212 that was described to the application in <unistd.h> or <limits.h>
213 when the application was compiled.
214
216 EINVAL name is invalid.
217
219 For an explanation of the terms used in this section, see
220 attributes(7).
221
222 ┌──────────┬───────────────┬─────────────┐
223 │Interface │ Attribute │ Value │
224 ├──────────┼───────────────┼─────────────┤
225 │sysconf() │ Thread safety │ MT-Safe env │
226 └──────────┴───────────────┴─────────────┘
228 POSIX.1-2001, POSIX.1-2008.
229
231 It is difficult to use ARG_MAX because it is not specified how much of
232 the argument space for exec(3) is consumed by the user's environment
233 variables.
234
235 Some returned values may be huge; they are not suitable for allocating
236 memory.
237
239 bc(1), expr(1), getconf(1), locale(1), confstr(3), fpathconf(3), path‐
240 conf(3), posixoptions(7)
241
243 This page is part of release 4.16 of the Linux man-pages project. A
244 description of the project, information about reporting bugs, and the
245 latest version of this page, can be found at
246 https://www.kernel.org/doc/man-pages/.
247
248
249
250GNU 2017-11-26 SYSCONF(3)