1sysconf(3) Library Functions Manual sysconf(3)
2
3
4
6 sysconf - get configuration information at run time
7
9 Standard C library (libc, -lc)
10
12 #include <unistd.h>
13
14 long sysconf(int name);
15
17 POSIX allows an application to test at compile or run time whether cer‐
18 tain options are supported, or what the value is of certain config‐
19 urable constants or limits.
20
21 At compile time this is done by including <unistd.h> and/or <limits.h>
22 and testing the value of certain macros.
23
24 At run time, one can ask for numerical values using the present func‐
25 tion sysconf(). One can ask for numerical values that may depend on
26 the filesystem in which a file resides using fpathconf(3) and path‐
27 conf(3). One can ask for string values using confstr(3).
28
29 The values obtained from these functions are system configuration con‐
30 stants. They do not change during the lifetime of a process.
31
32 For options, typically, there is a constant _POSIX_FOO that may be de‐
33 fined in <unistd.h>. If it is undefined, one should ask at run time.
34 If it is defined to -1, then the option is not supported. If it is de‐
35 fined to 0, then relevant functions and headers exist, but one has to
36 ask at run time what degree of support is available. If it is defined
37 to a value other than -1 or 0, then the option is supported. Usually
38 the value (such as 200112L) indicates the year and month of the POSIX
39 revision describing the option. glibc uses the value 1 to indicate
40 support as long as the POSIX revision has not been published yet. The
41 sysconf() argument will be _SC_FOO. For a list of options, see
42 posixoptions(7).
43
44 For variables or limits, typically, there is a constant _FOO, maybe de‐
45 fined in <limits.h>, or _POSIX_FOO, maybe defined in <unistd.h>. The
46 constant will not be defined if the limit is unspecified. If the con‐
47 stant is defined, it gives a guaranteed value, and a greater value
48 might actually be supported. If an application wants to take advantage
49 of values which may change between systems, a call to sysconf() can be
50 made. The sysconf() argument will be _SC_FOO.
51
52 POSIX.1 variables
53 We give the name of the variable, the name of the sysconf() argument
54 used to inquire about its value, and a short description.
55
56 First, the POSIX.1 compatible values.
57
58 ARG_MAX - _SC_ARG_MAX
59 The maximum length of the arguments to the exec(3) family of
60 functions. Must not be less than _POSIX_ARG_MAX (4096).
61
62 CHILD_MAX - _SC_CHILD_MAX
63 The maximum number of simultaneous processes per user ID. Must
64 not be less than _POSIX_CHILD_MAX (25).
65
66 HOST_NAME_MAX - _SC_HOST_NAME_MAX
67 Maximum length of a hostname, not including the terminating null
68 byte, as returned by gethostname(2). Must not be less than
69 _POSIX_HOST_NAME_MAX (255).
70
71 LOGIN_NAME_MAX - _SC_LOGIN_NAME_MAX
72 Maximum length of a login name, including the terminating null
73 byte. Must not be less than _POSIX_LOGIN_NAME_MAX (9).
74
75 NGROUPS_MAX - _SC_NGROUPS_MAX
76 Maximum number of supplementary group IDs.
77
78 clock ticks - _SC_CLK_TCK
79 The number of clock ticks per second. The corresponding vari‐
80 able is obsolete. It was of course called CLK_TCK. (Note: the
81 macro CLOCKS_PER_SEC does not give information: it must equal
82 1000000.)
83
84 OPEN_MAX - _SC_OPEN_MAX
85 The maximum number of files that a process can have open at any
86 time. Must not be less than _POSIX_OPEN_MAX (20).
87
88 PAGESIZE - _SC_PAGESIZE
89 Size of a page in bytes. Must not be less than 1.
90
91 PAGE_SIZE - _SC_PAGE_SIZE
92 A synonym for PAGESIZE/_SC_PAGESIZE. (Both PAGESIZE and
93 PAGE_SIZE are specified in POSIX.)
94
95 RE_DUP_MAX - _SC_RE_DUP_MAX
96 The number of repeated occurrences of a BRE permitted by
97 regexec(3) and regcomp(3). Must not be less than
98 _POSIX2_RE_DUP_MAX (255).
99
100 STREAM_MAX - _SC_STREAM_MAX
101 The maximum number of streams that a process can have open at
102 any time. If defined, it has the same value as the standard C
103 macro FOPEN_MAX. Must not be less than _POSIX_STREAM_MAX (8).
104
105 SYMLOOP_MAX - _SC_SYMLOOP_MAX
106 The maximum number of symbolic links seen in a pathname before
107 resolution returns ELOOP. Must not be less than _POSIX_SYM‐
108 LOOP_MAX (8).
109
110 TTY_NAME_MAX - _SC_TTY_NAME_MAX
111 The maximum length of terminal device name, including the termi‐
112 nating null byte. Must not be less than _POSIX_TTY_NAME_MAX
113 (9).
114
115 TZNAME_MAX - _SC_TZNAME_MAX
116 The maximum number of bytes in a timezone name. Must not be
117 less than _POSIX_TZNAME_MAX (6).
118
119 _POSIX_VERSION - _SC_VERSION
120 indicates the year and month the POSIX.1 standard was approved
121 in the format YYYYMML; the value 199009L indicates the Sept.
122 1990 revision.
123
124 POSIX.2 variables
125 Next, the POSIX.2 values, giving limits for utilities.
126
127 BC_BASE_MAX - _SC_BC_BASE_MAX
128 indicates the maximum obase value accepted by the bc(1) utility.
129
130 BC_DIM_MAX - _SC_BC_DIM_MAX
131 indicates the maximum value of elements permitted in an array by
132 bc(1).
133
134 BC_SCALE_MAX - _SC_BC_SCALE_MAX
135 indicates the maximum scale value allowed by bc(1).
136
137 BC_STRING_MAX - _SC_BC_STRING_MAX
138 indicates the maximum length of a string accepted by bc(1).
139
140 COLL_WEIGHTS_MAX - _SC_COLL_WEIGHTS_MAX
141 indicates the maximum numbers of weights that can be assigned to
142 an entry of the LC_COLLATE order keyword in the locale defini‐
143 tion file.
144
145 EXPR_NEST_MAX - _SC_EXPR_NEST_MAX
146 is the maximum number of expressions which can be nested within
147 parentheses by expr(1).
148
149 LINE_MAX - _SC_LINE_MAX
150 The maximum length of a utility's input line, either from stan‐
151 dard input or from a file. This includes space for a trailing
152 newline.
153
154 RE_DUP_MAX - _SC_RE_DUP_MAX
155 The maximum number of repeated occurrences of a regular expres‐
156 sion when the interval notation \{m,n\} is used.
157
158 POSIX2_VERSION - _SC_2_VERSION
159 indicates the version of the POSIX.2 standard in the format of
160 YYYYMML.
161
162 POSIX2_C_DEV - _SC_2_C_DEV
163 indicates whether the POSIX.2 C language development facilities
164 are supported.
165
166 POSIX2_FORT_DEV - _SC_2_FORT_DEV
167 indicates whether the POSIX.2 FORTRAN development utilities are
168 supported.
169
170 POSIX2_FORT_RUN - _SC_2_FORT_RUN
171 indicates whether the POSIX.2 FORTRAN run-time utilities are
172 supported.
173
174 _POSIX2_LOCALEDEF - _SC_2_LOCALEDEF
175 indicates whether the POSIX.2 creation of locales via lo‐
176 caledef(1) is supported.
177
178 POSIX2_SW_DEV - _SC_2_SW_DEV
179 indicates whether the POSIX.2 software development utilities op‐
180 tion is supported.
181
182 These values also exist, but may not be standard.
183
184 - _SC_PHYS_PAGES
185 The number of pages of physical memory. Note that it is possi‐
186 ble for the product of this value and the value of _SC_PAGESIZE
187 to overflow.
188
189 - _SC_AVPHYS_PAGES
190 The number of currently available pages of physical memory.
191
192 - _SC_NPROCESSORS_CONF
193 The number of processors configured. See also
194 get_nprocs_conf(3).
195
196 - _SC_NPROCESSORS_ONLN
197 The number of processors currently online (available). See also
198 get_nprocs_conf(3).
199
201 The return value of sysconf() is one of the following:
202
203 • On error, -1 is returned and errno is set to indicate the error (for
204 example, EINVAL, indicating that name is invalid).
205
206 • If name corresponds to a maximum or minimum limit, and that limit is
207 indeterminate, -1 is returned and errno is not changed. (To distin‐
208 guish an indeterminate limit from an error, set errno to zero before
209 the call, and then check whether errno is nonzero when -1 is re‐
210 turned.)
211
212 • If name corresponds to an option, a positive value is returned if
213 the option is supported, and -1 is returned if the option is not
214 supported.
215
216 • Otherwise, the current value of the option or limit is returned.
217 This value will not be more restrictive than the corresponding value
218 that was described to the application in <unistd.h> or <limits.h>
219 when the application was compiled.
220
222 EINVAL name is invalid.
223
225 For an explanation of the terms used in this section, see at‐
226 tributes(7).
227
228 ┌────────────────────────────────────────┬───────────────┬─────────────┐
229 │Interface │ Attribute │ Value │
230 ├────────────────────────────────────────┼───────────────┼─────────────┤
231 │sysconf() │ Thread safety │ MT-Safe env │
232 └────────────────────────────────────────┴───────────────┴─────────────┘
233
235 POSIX.1-2008.
236
238 POSIX.1-2001.
239
241 It is difficult to use ARG_MAX because it is not specified how much of
242 the argument space for exec(3) is consumed by the user's environment
243 variables.
244
245 Some returned values may be huge; they are not suitable for allocating
246 memory.
247
249 bc(1), expr(1), getconf(1), locale(1), confstr(3), fpathconf(3),
250 pathconf(3), posixoptions(7)
251
252
253
254Linux man-pages 6.05 2023-07-20 sysconf(3)