]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/sysconf.3
man*/: srcfix (Use .P instead of .PP or .LP)
[thirdparty/man-pages.git] / man3 / sysconf.3
CommitLineData
a1eaacb1 1'\" t
bf5a7247 2.\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
fea681da 3.\"
5fbde956 4.\" SPDX-License-Identifier: Linux-man-pages-copyleft
c08df37a 5.\"
fea681da
MK
6.\" Modified Sat Jul 24 17:51:42 1993 by Rik Faith (faith@cs.unc.edu)
7.\" Modified Tue Aug 17 11:42:20 1999 by Ariel Scolnicov (ariels@compugen.co.il)
4c1c5274 8.TH sysconf 3 (date) "Linux man-pages (unreleased)"
fea681da 9.SH NAME
72c90260 10sysconf \- get configuration information at run time
561292a8
AC
11.SH LIBRARY
12Standard C library
8fc3b2cf 13.RI ( libc ", " \-lc )
fea681da
MK
14.SH SYNOPSIS
15.nf
16.B #include <unistd.h>
c6d039a3 17.P
fea681da
MK
18.BI "long sysconf(int " "name" );
19.fi
20.SH DESCRIPTION
cf50118f 21POSIX allows an application to test at compile or run time
fea681da
MK
22whether certain options are supported, or what the value is
23of certain configurable constants or limits.
c6d039a3 24.P
fea681da
MK
25At compile time this is done by including
26.I <unistd.h>
27and/or
28.I <limits.h>
29and testing the value of certain macros.
c6d039a3 30.P
fea681da
MK
31At run time, one can ask for numerical values using the present function
32.BR sysconf ().
7d0db56e 33One can ask for numerical values that may depend
386732aa 34on the filesystem in which a file resides using
fea681da
MK
35.BR fpathconf (3)
36and
37.BR pathconf (3).
38One can ask for string values using
39.BR confstr (3).
c6d039a3 40.P
fea681da
MK
41The values obtained from these functions are system configuration constants.
42They do not change during the lifetime of a process.
43.\" except that sysconf(_SC_OPEN_MAX) may change answer after a call
0425de01 44.\" to setrlimit( ) which changes the RLIMIT_NOFILE soft limit
c6d039a3 45.P
fea681da
MK
46For options, typically, there is a constant
47.B _POSIX_FOO
48that may be defined in
49.IR <unistd.h> .
cf50118f 50If it is undefined, one should ask at run time.
fea681da
MK
51If it is defined to \-1, then the option is not supported.
52If it is defined to 0, then relevant functions and headers exist,
72c90260 53but one has to ask at run time what degree of support is available.
fea681da 54If it is defined to a value other than \-1 or 0, then the option is
c13182ef
MK
55supported.
56Usually the value (such as 200112L) indicates the year and month
57of the POSIX revision describing the option.
75c018a1 58glibc uses the value 1
fea681da
MK
59to indicate support as long as the POSIX revision has not been published yet.
60.\" and 999 to indicate support for options no longer present in the latest
61.\" standard. (?)
62The
63aa9df0 63.BR sysconf ()
fea681da
MK
64argument will be
65.BR _SC_FOO .
66For a list of options, see
67.BR posixoptions (7).
c6d039a3 68.P
fea681da
MK
69For variables or limits, typically, there is a constant
70.BR _FOO ,
71maybe defined in
72.IR <limits.h> ,
73or
74.BR _POSIX_FOO ,
75maybe defined in
76.IR <unistd.h> .
77The constant will not be defined if the limit is unspecified.
78If the constant is defined, it gives a guaranteed value, and
5c4045cb 79a greater value might actually be supported.
fea681da
MK
80If an application wants to take advantage of values which may change
81between systems, a call to
63aa9df0 82.BR sysconf ()
fea681da 83can be made.
c13182ef 84The
4a225b7a 85.BR sysconf ()
fea681da
MK
86argument will be
87.BR _SC_FOO .
73d8cece 88.SS POSIX.1 variables
fea681da 89We give the name of the variable, the name of the
63aa9df0 90.BR sysconf ()
c4bb193f 91argument used to inquire about its value,
fea681da 92and a short description.
c6d039a3 93.P
fea681da
MK
94First, the POSIX.1 compatible values.
95.\" [for the moment: only the things that are unconditionally present]
96.\" .TP
97.\" .BR AIO_LISTIO_MAX " - " _SC_AIO_LISTIO_MAX
98.\" (if _POSIX_ASYNCHRONOUS_IO)
99.\" Maximum number of I/O operations in a single list I/O call.
100.\" Must not be less than _POSIX_AIO_LISTIO_MAX.
101.\" .TP
102.\" .BR AIO_MAX " - " _SC_AIO_MAX
103.\" (if _POSIX_ASYNCHRONOUS_IO)
104.\" Maximum number of outstanding asynchronous I/O operations.
105.\" Must not be less than _POSIX_AIO_MAX.
106.\" .TP
107.\" .BR AIO_PRIO_DELTA_MAX " - " _SC_AIO_PRIO_DELTA_MAX
108.\" (if _POSIX_ASYNCHRONOUS_IO)
109.\" The maximum amount by which a process can decrease its
110.\" asynchronous I/O priority level from its own scheduling priority.
2fda57bd 111.\" Must be nonnegative.
fea681da
MK
112.TP
113.BR ARG_MAX " - " _SC_ARG_MAX
114The maximum length of the arguments to the
3a72373c 115.BR exec (3)
fea681da 116family of functions.
8c4f34f8
MK
117Must not be less than
118.B _POSIX_ARG_MAX
119(4096).
fea681da
MK
120.TP
121.BR CHILD_MAX " - " _SC_CHILD_MAX
82e07898 122The maximum number of simultaneous processes per user ID.
8c4f34f8
MK
123Must not be less than
124.B _POSIX_CHILD_MAX
125(25).
fea681da
MK
126.TP
127.BR HOST_NAME_MAX " - " _SC_HOST_NAME_MAX
82e07898 128Maximum length of a hostname, not including the terminating null byte,
28d88c17 129as returned by
fea681da 130.BR gethostname (2).
8c4f34f8
MK
131Must not be less than
132.B _POSIX_HOST_NAME_MAX
133(255).
fea681da
MK
134.TP
135.BR LOGIN_NAME_MAX " - " _SC_LOGIN_NAME_MAX
28d88c17 136Maximum length of a login name, including the terminating null byte.
8c4f34f8
MK
137Must not be less than
138.B _POSIX_LOGIN_NAME_MAX
139(9).
fea681da 140.TP
4d300f4a
JT
141.BR NGROUPS_MAX " - " _SC_NGROUPS_MAX
142Maximum number of supplementary group IDs.
143.TP
fea681da
MK
144.BR "" "clock ticks - " _SC_CLK_TCK
145The number of clock ticks per second.
c13182ef
MK
146The corresponding variable is obsolete.
147It was of course called
fea681da
MK
148.BR CLK_TCK .
149(Note: the macro
150.B CLOCKS_PER_SEC
151does not give information: it must equal 1000000.)
152.TP
153.BR OPEN_MAX " - " _SC_OPEN_MAX
154The maximum number of files that a process can have open at any time.
8c4f34f8
MK
155Must not be less than
156.B _POSIX_OPEN_MAX
157(20).
fea681da
MK
158.TP
159.BR PAGESIZE " - " _SC_PAGESIZE
c13182ef
MK
160Size of a page in bytes.
161Must not be less than 1.
f19efb02
MK
162.TP
163.BR PAGE_SIZE " - " _SC_PAGE_SIZE
164A synonym for
165.BR PAGESIZE / _SC_PAGESIZE .
166(Both
1ae6b2c7 167.B PAGESIZE
f19efb02 168and
1ae6b2c7 169.B PAGE_SIZE
f19efb02 170are specified in POSIX.)
fea681da
MK
171.TP
172.BR RE_DUP_MAX " - " _SC_RE_DUP_MAX
173The number of repeated occurrences of a BRE permitted by
174.BR regexec (3)
175and
176.BR regcomp (3).
8c4f34f8
MK
177Must not be less than
178.B _POSIX2_RE_DUP_MAX
179(255).
fea681da
MK
180.TP
181.BR STREAM_MAX " - " _SC_STREAM_MAX
182The maximum number of streams that a process can have open at any
c13182ef
MK
183time.
184If defined, it has the same value as the standard C macro
fea681da 185.BR FOPEN_MAX .
8c4f34f8
MK
186Must not be less than
187.B _POSIX_STREAM_MAX
188(8).
fea681da 189.TP
3dd1c10f 190.BR SYMLOOP_MAX " - " _SC_SYMLOOP_MAX
fea681da 191The maximum number of symbolic links seen in a pathname before resolution
097585ed
MK
192returns
193.BR ELOOP .
8c4f34f8
MK
194Must not be less than
195.B _POSIX_SYMLOOP_MAX
196(8).
fea681da
MK
197.TP
198.BR TTY_NAME_MAX " - " _SC_TTY_NAME_MAX
c13182ef 199The maximum length of terminal device name,
28d88c17 200including the terminating null byte.
8c4f34f8 201Must not be less than
0daa9e92 202.B _POSIX_TTY_NAME_MAX
8c4f34f8 203(9).
fea681da
MK
204.TP
205.BR TZNAME_MAX " - " _SC_TZNAME_MAX
206The maximum number of bytes in a timezone name.
8c4f34f8 207Must not be less than
0daa9e92 208.B _POSIX_TZNAME_MAX
8c4f34f8 209(6).
fea681da
MK
210.TP
211.BR _POSIX_VERSION " - " _SC_VERSION
212indicates the year and month the POSIX.1 standard was approved in the
213format
1368e847
MK
214.BR YYYYMML ;
215the value
fea681da
MK
216.B 199009L
217indicates the Sept. 1990 revision.
73d8cece 218.SS POSIX.2 variables
fea681da
MK
219Next, the POSIX.2 values, giving limits for utilities.
220.TP
221.BR BC_BASE_MAX " - " _SC_BC_BASE_MAX
222indicates the maximum
223.I obase
224value accepted by the
225.BR bc (1)
226utility.
227.TP
228.BR BC_DIM_MAX " - " _SC_BC_DIM_MAX
229indicates the maximum value of elements permitted in an array by
230.BR bc (1).
231.TP
232.BR BC_SCALE_MAX " - " _SC_BC_SCALE_MAX
233indicates the maximum
234.I scale
235value allowed by
236.BR bc (1).
237.TP
238.BR BC_STRING_MAX " - " _SC_BC_STRING_MAX
239indicates the maximum length of a string accepted by
240.BR bc (1).
241.TP
242.BR COLL_WEIGHTS_MAX " - " _SC_COLL_WEIGHTS_MAX
243indicates the maximum numbers of weights that can be assigned to an
244entry of the
245.B LC_COLLATE order
3b4edb13 246keyword in the locale definition file.
fea681da
MK
247.TP
248.BR EXPR_NEST_MAX " - " _SC_EXPR_NEST_MAX
249is the maximum number of expressions which can be nested within
250parentheses by
251.BR expr (1).
252.TP
253.BR LINE_MAX " - " _SC_LINE_MAX
4a5d77d4 254The maximum length of a utility's input line, either from
c13182ef 255standard input or from a file.
fa233003 256This includes space for a trailing
fea681da
MK
257newline.
258.TP
259.BR RE_DUP_MAX " - " _SC_RE_DUP_MAX
260The maximum number of repeated occurrences of a regular expression when
261the interval notation
31a6818e 262.B \e{m,n\e}
fea681da
MK
263is used.
264.TP
265.BR POSIX2_VERSION " - " _SC_2_VERSION
266indicates the version of the POSIX.2 standard in the format of
267YYYYMML.
268.TP
961abb97 269.BR POSIX2_C_DEV " - " _SC_2_C_DEV
fea681da
MK
270indicates whether the POSIX.2 C language development facilities are
271supported.
272.TP
50a0922f 273.BR POSIX2_FORT_DEV " - " _SC_2_FORT_DEV
fea681da
MK
274indicates whether the POSIX.2 FORTRAN development utilities are
275supported.
276.TP
277.BR POSIX2_FORT_RUN " - " _SC_2_FORT_RUN
72c90260 278indicates whether the POSIX.2 FORTRAN run-time utilities are supported.
fea681da
MK
279.TP
280.BR _POSIX2_LOCALEDEF " - " _SC_2_LOCALEDEF
ff338578 281indicates whether the POSIX.2 creation of locales via
fea681da
MK
282.BR localedef (1)
283is supported.
284.TP
285.BR POSIX2_SW_DEV " - " _SC_2_SW_DEV
286indicates whether the POSIX.2 software development utilities option is
287supported.
c6d039a3 288.P
fea681da
MK
289These values also exist, but may not be standard.
290.TP
291.BR "" " - " _SC_PHYS_PAGES
c13182ef
MK
292The number of pages of physical memory.
293Note that it is possible
fea681da 294for the product of this value and the value of
c9764208 295.B _SC_PAGESIZE
fea681da
MK
296to overflow.
297.TP
298.BR "" " - " _SC_AVPHYS_PAGES
299The number of currently available pages of physical memory.
a19d984e
MK
300.TP
301.BR "" " - " _SC_NPROCESSORS_CONF
302The number of processors configured.
39a6b7e8
MK
303See also
304.BR get_nprocs_conf (3).
a19d984e
MK
305.TP
306.BR "" " - " _SC_NPROCESSORS_ONLN
307The number of processors currently online (available).
39a6b7e8
MK
308See also
309.BR get_nprocs_conf (3).
47297adb 310.SH RETURN VALUE
480ef6d9
MK
311The return value of
312.BR sysconf ()
313is one of the following:
cdede5cd 314.IP \[bu] 3
480ef6d9
MK
315On error, \-1 is returned and
316.I errno
855d489a 317is set to indicate the error
480ef6d9
MK
318(for example,
319.BR EINVAL ,
320indicating that
321.I name
322is invalid).
cdede5cd 323.IP \[bu]
fea681da
MK
324If
325.I name
480ef6d9
MK
326corresponds to a maximum or minimum limit, and that limit is indeterminate,
327\-1 is returned and
fea681da
MK
328.I errno
329is not changed.
480ef6d9
MK
330(To distinguish an indeterminate limit from an error, set
331.I errno
332to zero before the call, and then check whether
333.I errno
334is nonzero when \-1 is returned.)
cdede5cd 335.IP \[bu]
480ef6d9
MK
336If
337.I name
338corresponds to an option,
339a positive value is returned if the option is supported,
340and \-1 is returned if the option is not supported.
cdede5cd 341.IP \[bu]
480ef6d9
MK
342Otherwise,
343the current value of the option or limit is returned.
344This value will not be more restrictive than
345the corresponding value that was described to the application in
346.I <unistd.h>
347or
348.I <limits.h>
349when the application was compiled.
646896d3
MK
350.SH ERRORS
351.TP
352.B EINVAL
353.I name
354is invalid.
dfcbc01f
ZL
355.SH ATTRIBUTES
356For an explanation of the terms used in this section, see
357.BR attributes (7).
358.TS
359allbox;
c466875e 360lbx lb lb
dfcbc01f
ZL
361l l l.
362Interface Attribute Value
363T{
9e54434e
BR
364.na
365.nh
dfcbc01f
ZL
366.BR sysconf ()
367T} Thread safety MT-Safe env
368.TE
3113c7f3 369.SH STANDARDS
4131356c
AC
370POSIX.1-2008.
371.SH HISTORY
372POSIX.1-2001.
fea681da
MK
373.SH BUGS
374It is difficult to use
375.B ARG_MAX
376because it is not specified how much of the argument space for
3a72373c 377.BR exec (3)
fea681da 378is consumed by the user's environment variables.
c6d039a3 379.P
fea681da
MK
380Some returned values may be huge; they are not suitable for allocating
381memory.
47297adb 382.SH SEE ALSO
fea681da
MK
383.BR bc (1),
384.BR expr (1),
ceff5191 385.BR getconf (1),
fea681da 386.BR locale (1),
e812955a 387.BR confstr (3),
fea681da
MK
388.BR fpathconf (3),
389.BR pathconf (3),
390.BR posixoptions (7)