summaryrefslogtreecommitdiffstats
path: root/man3/sysconf.3
blob: 29ce6bde5d3ab1d0c51fbf3403a181488e730701 (plain)
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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
'\" t
.\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
.\" 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 2023-10-31 "Linux man-pages 6.7"
.SH NAME
sysconf \- get configuration information at run time
.SH LIBRARY
Standard C library
.RI ( libc ", " \-lc )
.SH SYNOPSIS
.nf
.B #include <unistd.h>
.P
.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.
.P
At compile time this is done by including
.I <unistd.h>
and/or
.I <limits.h>
and testing the value of certain macros.
.P
At run time, one can ask for numerical values using the present function
.BR sysconf ().
One can ask for numerical values that may depend
on the filesystem in which a file resides using
.BR fpathconf (3)
and
.BR pathconf (3).
One can ask for string values using
.BR confstr (3).
.P
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
.P
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 run time 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).
.P
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.
.P
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 nonnegative.
.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 maximum 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
Maximum 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 NGROUPS_MAX " - " _SC_NGROUPS_MAX
Maximum number of supplementary group IDs.
.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.
.TP
.BR PAGE_SIZE " - " _SC_PAGE_SIZE
A synonym for
.BR PAGESIZE / _SC_PAGESIZE .
(Both
.B PAGESIZE
and
.B PAGE_SIZE
are specified in POSIX.)
.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
.BR SYMLOOP_MAX " - " _SC_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, either from
standard input or from a file.
This includes space 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 run-time utilities are supported.
.TP
.BR _POSIX2_LOCALEDEF " - " _SC_2_LOCALEDEF
indicates whether the POSIX.2 creation of locales 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.
.P
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_PAGESIZE
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.
See also
.BR get_nprocs_conf (3).
.TP
.BR "" " - " _SC_NPROCESSORS_ONLN
The number of processors currently online (available).
See also
.BR get_nprocs_conf (3).
.SH RETURN VALUE
The return value of
.BR sysconf ()
is one of the following:
.IP \[bu] 3
On error, \-1 is returned and
.I errno
is set to indicate the error
(for example,
.BR EINVAL ,
indicating that
.I name
is invalid).
.IP \[bu]
If
.I name
corresponds to a maximum or minimum limit, and that limit is indeterminate,
\-1 is returned and
.I errno
is not changed.
(To distinguish an indeterminate limit from an error, set
.I errno
to zero before the call, and then check whether
.I errno
is nonzero when \-1 is returned.)
.IP \[bu]
If
.I name
corresponds to an option,
a positive value is returned if the option is supported,
and \-1 is returned if the option is not supported.
.IP \[bu]
Otherwise,
the current value of the option or limit is returned.
This value will not be more restrictive than
the corresponding value that was described to the application in
.I <unistd.h>
or
.I <limits.h>
when the application was compiled.
.SH ERRORS
.TP
.B EINVAL
.I name
is invalid.
.SH ATTRIBUTES
For an explanation of the terms used in this section, see
.BR attributes (7).
.TS
allbox;
lbx lb lb
l l l.
Interface	Attribute	Value
T{
.na
.nh
.BR sysconf ()
T}	Thread safety	MT-Safe env
.TE
.SH STANDARDS
POSIX.1-2008.
.SH HISTORY
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.
.P
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 confstr (3),
.BR fpathconf (3),
.BR pathconf (3),
.BR posixoptions (7)