1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
|
.\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date. The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein. The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\" License.
.\" Modified Sat Jul 24 17:51:42 1993 by Rik Faith (faith@cs.unc.edu)
.\" Modified Tue Aug 17 11:42:20 1999 by Ariel Scolnicov (ariels@compugen.co.il)
.TH SYSCONF 3 2007-12-12 "GNU" "Linux Programmer's Manual"
.SH NAME
sysconf \- Get configuration information at runtime
.SH SYNOPSIS
.nf
.B #include <unistd.h>
.sp
.BI "long sysconf(int " "name" );
.fi
.SH DESCRIPTION
POSIX allows an application to test at compile or run time
whether certain options are supported, or what the value is
of certain configurable constants or limits.
.LP
At compile time this is done by including
.I <unistd.h>
and/or
.I <limits.h>
and testing the value of certain macros.
.LP
At run time, one can ask for numerical values using the present function
.BR sysconf ().
On can ask for numerical values that may depend
on the file system a file is in using the calls
.BR fpathconf (3)
and
.BR pathconf (3).
One can ask for string values using
.BR confstr (3).
.LP
The values obtained from these functions are system configuration constants.
They do not change during the lifetime of a process.
.\" except that sysconf(_SC_OPEN_MAX) may change answer after a call
.\" to setrlimit( ) which changes the RLIMIT_NOFILE soft limit
.LP
For options, typically, there is a constant
.B _POSIX_FOO
that may be defined in
.IR <unistd.h> .
If it is undefined, one should ask at run time.
If it is defined to \-1, then the option is not supported.
If it is defined to 0, then relevant functions and headers exist,
but one has to ask at runtime what degree of support is available.
If it is defined to a value other than \-1 or 0, then the option is
supported.
Usually the value (such as 200112L) indicates the year and month
of the POSIX revision describing the option.
Glibc uses the value 1
to indicate support as long as the POSIX revision has not been published yet.
.\" and 999 to indicate support for options no longer present in the latest
.\" standard. (?)
The
.BR sysconf ()
argument will be
.BR _SC_FOO .
For a list of options, see
.BR posixoptions (7).
.LP
For variables or limits, typically, there is a constant
.BR _FOO ,
maybe defined in
.IR <limits.h> ,
or
.BR _POSIX_FOO ,
maybe defined in
.IR <unistd.h> .
The constant will not be defined if the limit is unspecified.
If the constant is defined, it gives a guaranteed value, and
a greater value might actually be supported.
If an application wants to take advantage of values which may change
between systems, a call to
.BR sysconf ()
can be made.
The
.BR sysconf ()
argument will be
.BR _SC_FOO .
.SS "POSIX.1 Variables"
We give the name of the variable, the name of the
.BR sysconf ()
argument used to inquire about its value,
and a short description.
.LP
First, the POSIX.1 compatible values.
.\" [for the moment: only the things that are unconditionally present]
.\" .TP
.\" .BR AIO_LISTIO_MAX " - " _SC_AIO_LISTIO_MAX
.\" (if _POSIX_ASYNCHRONOUS_IO)
.\" Maximum number of I/O operations in a single list I/O call.
.\" Must not be less than _POSIX_AIO_LISTIO_MAX.
.\" .TP
.\" .BR AIO_MAX " - " _SC_AIO_MAX
.\" (if _POSIX_ASYNCHRONOUS_IO)
.\" Maximum number of outstanding asynchronous I/O operations.
.\" Must not be less than _POSIX_AIO_MAX.
.\" .TP
.\" .BR AIO_PRIO_DELTA_MAX " - " _SC_AIO_PRIO_DELTA_MAX
.\" (if _POSIX_ASYNCHRONOUS_IO)
.\" The maximum amount by which a process can decrease its
.\" asynchronous I/O priority level from its own scheduling priority.
.\" Must be non-negative.
.TP
.BR ARG_MAX " - " _SC_ARG_MAX
The maximum length of the arguments to the
.BR exec (3)
family of functions.
Must not be less than
.B _POSIX_ARG_MAX
(4096).
.TP
.BR CHILD_MAX " - " _SC_CHILD_MAX
The max number of simultaneous processes per user ID.
Must not be less than
.B _POSIX_CHILD_MAX
(25).
.TP
.BR HOST_NAME_MAX " - " _SC_HOST_NAME_MAX
Max length of a hostname, not including the terminating null byte,
as returned by
.BR gethostname (2).
Must not be less than
.B _POSIX_HOST_NAME_MAX
(255).
.TP
.BR LOGIN_NAME_MAX " - " _SC_LOGIN_NAME_MAX
Maximum length of a login name, including the terminating null byte.
Must not be less than
.B _POSIX_LOGIN_NAME_MAX
(9).
.TP
.BR "" "clock ticks - " _SC_CLK_TCK
The number of clock ticks per second.
The corresponding variable is obsolete.
It was of course called
.BR CLK_TCK .
(Note: the macro
.B CLOCKS_PER_SEC
does not give information: it must equal 1000000.)
.TP
.BR OPEN_MAX " - " _SC_OPEN_MAX
The maximum number of files that a process can have open at any time.
Must not be less than
.B _POSIX_OPEN_MAX
(20).
.TP
.BR PAGESIZE " - " _SC_PAGESIZE
Size of a page in bytes.
Must not be less than 1.
(Some systems use PAGE_SIZE instead.)
.TP
.BR RE_DUP_MAX " - " _SC_RE_DUP_MAX
The number of repeated occurrences of a BRE permitted by
.BR regexec (3)
and
.BR regcomp (3).
Must not be less than
.B _POSIX2_RE_DUP_MAX
(255).
.TP
.BR STREAM_MAX " - " _SC_STREAM_MAX
The maximum number of streams that a process can have open at any
time.
If defined, it has the same value as the standard C macro
.BR FOPEN_MAX .
Must not be less than
.B _POSIX_STREAM_MAX
(8).
.TP
.B SYMLOOP_MAX
The maximum number of symbolic links seen in a pathname before resolution
returns
.BR ELOOP .
Must not be less than
.B _POSIX_SYMLOOP_MAX
(8).
.TP
.BR TTY_NAME_MAX " - " _SC_TTY_NAME_MAX
The maximum length of terminal device name,
including the terminating null byte.
Must not be less than
.B _POSIX_TTY_NAME_MAX
(9).
.TP
.BR TZNAME_MAX " - " _SC_TZNAME_MAX
The maximum number of bytes in a timezone name.
Must not be less than
.B _POSIX_TZNAME_MAX
(6).
.TP
.BR _POSIX_VERSION " - " _SC_VERSION
indicates the year and month the POSIX.1 standard was approved in the
format
.BR YYYYMML ;
the value
.B 199009L
indicates the Sept. 1990 revision.
.SS "POSIX.2 Variables"
Next, the POSIX.2 values, giving limits for utilities.
.TP
.BR BC_BASE_MAX " - " _SC_BC_BASE_MAX
indicates the maximum
.I obase
value accepted by the
.BR bc (1)
utility.
.TP
.BR BC_DIM_MAX " - " _SC_BC_DIM_MAX
indicates the maximum value of elements permitted in an array by
.BR bc (1).
.TP
.BR BC_SCALE_MAX " - " _SC_BC_SCALE_MAX
indicates the maximum
.I scale
value allowed by
.BR bc (1).
.TP
.BR BC_STRING_MAX " - " _SC_BC_STRING_MAX
indicates the maximum length of a string accepted by
.BR bc (1).
.TP
.BR COLL_WEIGHTS_MAX " - " _SC_COLL_WEIGHTS_MAX
indicates the maximum numbers of weights that can be assigned to an
entry of the
.B LC_COLLATE order
keyword in the locale definition file,
.TP
.BR EXPR_NEST_MAX " - " _SC_EXPR_NEST_MAX
is the maximum number of expressions which can be nested within
parentheses by
.BR expr (1).
.TP
.BR LINE_MAX " - " _SC_LINE_MAX
The maximum length of a utility's input line length, either from
standard input or from a file.
This includes length for a trailing
newline.
.TP
.BR RE_DUP_MAX " - " _SC_RE_DUP_MAX
The maximum number of repeated occurrences of a regular expression when
the interval notation
.B \e{m,n\e}
is used.
.TP
.BR POSIX2_VERSION " - " _SC_2_VERSION
indicates the version of the POSIX.2 standard in the format of
YYYYMML.
.TP
.BR POSIX2_C_DEV " - " _SC_2_C_DEV
indicates whether the POSIX.2 C language development facilities are
supported.
.TP
.BR POSIX2_FORT_DEV " - " _SC_2_FORT_DEV
indicates whether the POSIX.2 FORTRAN development utilities are
supported.
.TP
.BR POSIX2_FORT_RUN " - " _SC_2_FORT_RUN
indicates whether the POSIX.2 FORTRAN runtime utilities are supported.
.TP
.BR _POSIX2_LOCALEDEF " - " _SC_2_LOCALEDEF
indicates whether the POSIX.2 creation of locates via
.BR localedef (1)
is supported.
.TP
.BR POSIX2_SW_DEV " - " _SC_2_SW_DEV
indicates whether the POSIX.2 software development utilities option is
supported.
.PP
These values also exist, but may not be standard.
.TP
.BR "" " - " _SC_PHYS_PAGES
The number of pages of physical memory.
Note that it is possible
for the product of this value and the value of
.B _SC_PAGE_SIZE
to overflow.
.TP
.BR "" " - " _SC_AVPHYS_PAGES
The number of currently available pages of physical memory.
.TP
.BR "" " - " _SC_NPROCESSORS_CONF
The number of processors configured.
.TP
.BR "" " - " _SC_NPROCESSORS_ONLN
The number of processors currently online (available).
.SH "RETURN VALUE"
If
.I name
is invalid, \-1 is returned, and
.I errno
is set to
.BR EINVAL .
Otherwise, the value returned is the value of the system resource and
.I errno
is not changed.
In the case of options, a positive value is returned if a queried option
is available, and \-1 if it is not.
In the case of limits, \-1 means that there is no definite limit.
.SH "CONFORMING TO"
POSIX.1-2001.
.SH BUGS
It is difficult to use
.B ARG_MAX
because it is not specified how much of the argument space for
.BR exec (3)
is consumed by the user's environment variables.
.PP
Some returned values may be huge; they are not suitable for allocating
memory.
.SH "SEE ALSO"
.BR bc (1),
.BR expr (1),
.BR getconf (1),
.BR locale (1),
.BR fpathconf (3),
.BR pathconf (3),
.BR posixoptions (7)
|