OSDN Git Service

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