Update.
[platform/upstream/glibc.git] / manual / conf.texi
1 @c This node must have no pointers.
2 @node System Configuration
3 @c @node System Configuration, , System Information, Top
4 @c %MENU% Parameters describing operating system limits
5 @chapter System Configuration Parameters
6
7 The functions and macros listed in this chapter give information about
8 configuration parameters of the operating system---for example, capacity
9 limits, presence of optional POSIX features, and the default path for
10 executable files (@pxref{String Parameters}).
11
12 @menu
13 * General Limits::           Constants and functions that describe
14                                 various process-related limits that have
15                                 one uniform value for any given machine.
16 * System Options::           Optional POSIX features.
17 * Version Supported::        Version numbers of POSIX.1 and POSIX.2.
18 * Sysconf::                  Getting specific configuration values
19                                 of general limits and system options.
20 * Minimums::                 Minimum values for general limits.
21
22 * Limits for Files::         Size limitations that pertain to individual files.
23                                 These can vary between file systems
24                                 or even from file to file.
25 * Options for Files::        Optional features that some files may support.
26 * File Minimums::            Minimum values for file limits.
27 * Pathconf::                 Getting the limit values for a particular file.
28
29 * Utility Limits::           Capacity limits of some POSIX.2 utility programs.
30 * Utility Minimums::         Minimum allowable values of those limits.
31
32 * String Parameters::        Getting the default search path.
33 @end menu
34
35 @node General Limits
36 @section General Capacity Limits
37 @cindex POSIX capacity limits
38 @cindex limits, POSIX
39 @cindex capacity limits, POSIX
40
41 The POSIX.1 and POSIX.2 standards specify a number of parameters that
42 describe capacity limitations of the system.  These limits can be fixed
43 constants for a given operating system, or they can vary from machine to
44 machine.  For example, some limit values may be configurable by the
45 system administrator, either at run time or by rebuilding the kernel,
46 and this should not require recompiling application programs.
47
48 @pindex limits.h
49 Each of the following limit parameters has a macro that is defined in
50 @file{limits.h} only if the system has a fixed, uniform limit for the
51 parameter in question.  If the system allows different file systems or
52 files to have different limits, then the macro is undefined; use
53 @code{sysconf} to find out the limit that applies at a particular time
54 on a particular machine.  @xref{Sysconf}.
55
56 Each of these parameters also has another macro, with a name starting
57 with @samp{_POSIX}, which gives the lowest value that the limit is
58 allowed to have on @emph{any} POSIX system.  @xref{Minimums}.
59
60 @cindex limits, program argument size
61 @comment limits.h
62 @comment POSIX.1
63 @deftypevr Macro int ARG_MAX
64 If defined, the unvarying maximum combined length of the @var{argv} and
65 @var{environ} arguments that can be passed to the @code{exec} functions.
66 @end deftypevr
67
68 @cindex limits, number of processes
69 @comment limits.h
70 @comment POSIX.1
71 @deftypevr Macro int CHILD_MAX
72 If defined, the unvarying maximum number of processes that can exist
73 with the same real user ID at any one time.  In BSD and GNU, this is
74 controlled by the @code{RLIMIT_NPROC} resource limit; @pxref{Limits on
75 Resources}.
76 @end deftypevr
77
78 @cindex limits, number of open files
79 @comment limits.h
80 @comment POSIX.1
81 @deftypevr Macro int OPEN_MAX
82 If defined, the unvarying maximum number of files that a single process
83 can have open simultaneously.  In BSD and GNU, this is controlled
84 by the @code{RLIMIT_NOFILE} resource limit; @pxref{Limits on Resources}.
85 @end deftypevr
86
87 @comment limits.h
88 @comment POSIX.1
89 @deftypevr Macro int STREAM_MAX
90 If defined, the unvarying maximum number of streams that a single
91 process can have open simultaneously.  @xref{Opening Streams}.
92 @end deftypevr
93
94 @cindex limits, time zone name length
95 @comment limits.h
96 @comment POSIX.1
97 @deftypevr Macro int TZNAME_MAX
98 If defined, the unvarying maximum length of a time zone name.
99 @xref{Time Zone Functions}.
100 @end deftypevr
101
102 These limit macros are always defined in @file{limits.h}.
103
104 @cindex limits, number of supplementary group IDs
105 @comment limits.h
106 @comment POSIX.1
107 @deftypevr Macro int NGROUPS_MAX
108 The maximum number of supplementary group IDs that one process can have.
109
110 The value of this macro is actually a lower bound for the maximum.  That
111 is, you can count on being able to have that many supplementary group
112 IDs, but a particular machine might let you have even more.  You can use
113 @code{sysconf} to see whether a particular machine will let you have
114 more (@pxref{Sysconf}).
115 @end deftypevr
116
117 @comment limits.h
118 @comment POSIX.1
119 @deftypevr Macro int SSIZE_MAX
120 The largest value that can fit in an object of type @code{ssize_t}.
121 Effectively, this is the limit on the number of bytes that can be read
122 or written in a single operation.
123
124 This macro is defined in all POSIX systems because this limit is never
125 configurable.
126 @end deftypevr
127
128 @comment limits.h
129 @comment POSIX.2
130 @deftypevr Macro int RE_DUP_MAX
131 The largest number of repetitions you are guaranteed is allowed in the
132 construct @samp{\@{@var{min},@var{max}\@}} in a regular expression.
133
134 The value of this macro is actually a lower bound for the maximum.  That
135 is, you can count on being able to have that many repetitions, but a
136 particular machine might let you have even more.  You can use
137 @code{sysconf} to see whether a particular machine will let you have
138 more (@pxref{Sysconf}).  And even the value that @code{sysconf} tells
139 you is just a lower bound---larger values might work.
140
141 This macro is defined in all POSIX.2 systems, because POSIX.2 says it
142 should always be defined even if there is no specific imposed limit.
143 @end deftypevr
144
145 @node System Options
146 @section Overall System Options
147 @cindex POSIX optional features
148 @cindex optional POSIX features
149
150 POSIX defines certain system-specific options that not all POSIX systems
151 support.  Since these options are provided in the kernel, not in the
152 library, simply using the GNU C library does not guarantee any of these
153 features is supported; it depends on the system you are using.
154
155 @pindex unistd.h
156 You can test for the availability of a given option using the macros in
157 this section, together with the function @code{sysconf}.  The macros are
158 defined only if you include @file{unistd.h}.
159
160 For the following macros, if the macro is defined in @file{unistd.h},
161 then the option is supported.  Otherwise, the option may or may not be
162 supported; use @code{sysconf} to find out.  @xref{Sysconf}.
163
164 @comment unistd.h
165 @comment POSIX.1
166 @deftypevr Macro int _POSIX_JOB_CONTROL
167 If this symbol is defined, it indicates that the system supports job
168 control.  Otherwise, the implementation behaves as if all processes
169 within a session belong to a single process group.  @xref{Job Control}.
170 @end deftypevr
171
172 @comment unistd.h
173 @comment POSIX.1
174 @deftypevr Macro int _POSIX_SAVED_IDS
175 If this symbol is defined, it indicates that the system remembers the
176 effective user and group IDs of a process before it executes an
177 executable file with the set-user-ID or set-group-ID bits set, and that
178 explicitly changing the effective user or group IDs back to these values
179 is permitted.  If this option is not defined, then if a nonprivileged
180 process changes its effective user or group ID to the real user or group
181 ID of the process, it can't change it back again.  @xref{Enable/Disable
182 Setuid}.
183 @end deftypevr
184
185 For the following macros, if the macro is defined in @file{unistd.h},
186 then its value indicates whether the option is supported.  A value of
187 @code{-1} means no, and any other value means yes.  If the macro is not
188 defined, then the option may or may not be supported; use @code{sysconf}
189 to find out.  @xref{Sysconf}.
190
191 @comment unistd.h
192 @comment POSIX.2
193 @deftypevr Macro int _POSIX2_C_DEV
194 If this symbol is defined, it indicates that the system has the POSIX.2
195 C compiler command, @code{c89}.  The GNU C library always defines this
196 as @code{1}, on the assumption that you would not have installed it if
197 you didn't have a C compiler.
198 @end deftypevr
199
200 @comment unistd.h
201 @comment POSIX.2
202 @deftypevr Macro int _POSIX2_FORT_DEV
203 If this symbol is defined, it indicates that the system has the POSIX.2
204 Fortran compiler command, @code{fort77}.  The GNU C library never
205 defines this, because we don't know what the system has.
206 @end deftypevr
207
208 @comment unistd.h
209 @comment POSIX.2
210 @deftypevr Macro int _POSIX2_FORT_RUN
211 If this symbol is defined, it indicates that the system has the POSIX.2
212 @code{asa} command to interpret Fortran carriage control.  The GNU C
213 library never defines this, because we don't know what the system has.
214 @end deftypevr
215
216 @comment unistd.h
217 @comment POSIX.2
218 @deftypevr Macro int _POSIX2_LOCALEDEF
219 If this symbol is defined, it indicates that the system has the POSIX.2
220 @code{localedef} command.  The GNU C library never defines this, because
221 we don't know what the system has.
222 @end deftypevr
223
224 @comment unistd.h
225 @comment POSIX.2
226 @deftypevr Macro int _POSIX2_SW_DEV
227 If this symbol is defined, it indicates that the system has the POSIX.2
228 commands @code{ar}, @code{make}, and @code{strip}.  The GNU C library
229 always defines this as @code{1}, on the assumption that you had to have
230 @code{ar} and @code{make} to install the library, and it's unlikely that
231 @code{strip} would be absent when those are present.
232 @end deftypevr
233
234 @node Version Supported
235 @section Which Version of POSIX is Supported
236
237 @comment unistd.h
238 @comment POSIX.1
239 @deftypevr Macro {long int} _POSIX_VERSION
240 This constant represents the version of the POSIX.1 standard to which
241 the implementation conforms.  For an implementation conforming to the
242 1995 POSIX.1 standard, the value is the integer @code{199506L}.
243
244 @code{_POSIX_VERSION} is always defined (in @file{unistd.h}) in any
245 POSIX system.
246
247 @strong{Usage Note:} Don't try to test whether the system supports POSIX
248 by including @file{unistd.h} and then checking whether
249 @code{_POSIX_VERSION} is defined.  On a non-POSIX system, this will
250 probably fail because there is no @file{unistd.h}.  We do not know of
251 @emph{any} way you can reliably test at compilation time whether your
252 target system supports POSIX or whether @file{unistd.h} exists.
253
254 The GNU C compiler predefines the symbol @code{__POSIX__} if the target
255 system is a POSIX system.  Provided you do not use any other compilers
256 on POSIX systems, testing @code{defined (__POSIX__)} will reliably
257 detect such systems.
258 @end deftypevr
259
260 @comment unistd.h
261 @comment POSIX.2
262 @deftypevr Macro {long int} _POSIX2_C_VERSION
263 This constant represents the version of the POSIX.2 standard which the
264 library and system kernel support.  We don't know what value this will
265 be for the first version of the POSIX.2 standard, because the value is
266 based on the year and month in which the standard is officially adopted.
267
268 The value of this symbol says nothing about the utilities installed on
269 the system.
270
271 @strong{Usage Note:} You can use this macro to tell whether a POSIX.1
272 system library supports POSIX.2 as well.  Any POSIX.1 system contains
273 @file{unistd.h}, so include that file and then test @code{defined
274 (_POSIX2_C_VERSION)}.
275 @end deftypevr
276
277 @node Sysconf
278 @section Using @code{sysconf}
279
280 When your system has configurable system limits, you can use the
281 @code{sysconf} function to find out the value that applies to any
282 particular machine.  The function and the associated @var{parameter}
283 constants are declared in the header file @file{unistd.h}.
284
285 @menu
286 * Sysconf Definition::        Detailed specifications of @code{sysconf}.
287 * Constants for Sysconf::     The list of parameters @code{sysconf} can read.
288 * Examples of Sysconf::       How to use @code{sysconf} and the parameter
289                                  macros properly together.
290 @end menu
291
292 @node Sysconf Definition
293 @subsection Definition of @code{sysconf}
294
295 @comment unistd.h
296 @comment POSIX.1
297 @deftypefun {long int} sysconf (int @var{parameter})
298 This function is used to inquire about runtime system parameters.  The
299 @var{parameter} argument should be one of the @samp{_SC_} symbols listed
300 below.
301
302 The normal return value from @code{sysconf} is the value you requested.
303 A value of @code{-1} is returned both if the implementation does not
304 impose a limit, and in case of an error.
305
306 The following @code{errno} error conditions are defined for this function:
307
308 @table @code
309 @item EINVAL
310 The value of the @var{parameter} is invalid.
311 @end table
312 @end deftypefun
313
314 @node Constants for Sysconf
315 @subsection Constants for @code{sysconf} Parameters
316
317 Here are the symbolic constants for use as the @var{parameter} argument
318 to @code{sysconf}.  The values are all integer constants (more
319 specifically, enumeration type values).
320
321 @table @code
322 @comment unistd.h
323 @comment POSIX.1
324 @item _SC_ARG_MAX
325 Inquire about the parameter corresponding to @code{ARG_MAX}.
326
327 @comment unistd.h
328 @comment POSIX.1
329 @item _SC_CHILD_MAX
330 Inquire about the parameter corresponding to @code{CHILD_MAX}.
331
332 @comment unistd.h
333 @comment POSIX.1
334 @item _SC_OPEN_MAX
335 Inquire about the parameter corresponding to @code{OPEN_MAX}.
336
337 @comment unistd.h
338 @comment POSIX.1
339 @item _SC_STREAM_MAX
340 Inquire about the parameter corresponding to @code{STREAM_MAX}.
341
342 @comment unistd.h
343 @comment POSIX.1
344 @item _SC_TZNAME_MAX
345 Inquire about the parameter corresponding to @code{TZNAME_MAX}.
346
347 @comment unistd.h
348 @comment POSIX.1
349 @item _SC_NGROUPS_MAX
350 Inquire about the parameter corresponding to @code{NGROUPS_MAX}.
351
352 @comment unistd.h
353 @comment POSIX.1
354 @item _SC_JOB_CONTROL
355 Inquire about the parameter corresponding to @code{_POSIX_JOB_CONTROL}.
356
357 @comment unistd.h
358 @comment POSIX.1
359 @item _SC_SAVED_IDS
360 Inquire about the parameter corresponding to @code{_POSIX_SAVED_IDS}.
361
362 @comment unistd.h
363 @comment POSIX.1
364 @item _SC_VERSION
365 Inquire about the parameter corresponding to @code{_POSIX_VERSION}.
366
367 @comment unistd.h
368 @comment POSIX.1
369 @item _SC_CLK_TCK
370 Inquire about the parameter corresponding to @code{CLOCKS_PER_SEC};
371 @pxref{Basic CPU Time}.
372
373 @comment unistd.h
374 @comment GNU
375 @item _SC_CHARCLASS_NAME_MAX
376 Inquire about the parameter corresponding to maximal length allowed for
377 a character class name in an extended locale specification.  These
378 extensions are not yet standardized and so this option is not standardized
379 as well.
380
381 @comment unistdh.h
382 @comment POSIX.1
383 @item _SC_REALTIME_SIGNALS
384 Inquire about the parameter corresponding to @code{_POSIX_REALTIME_SIGNALS}.
385
386 @comment unistd.h
387 @comment POSIX.1
388 @item _SC_PRIORITY_SCHEDULING
389 Inquire about the parameter corresponding to @code{_POSIX_PRIORITY_SCHEDULING}.
390
391 @comment unistd.h
392 @comment POSIX.1
393 @item _SC_TIMERS
394 Inquire about the parameter corresponding to @code{_POSIX_TIMERS}.
395
396 @comment unistd.h
397 @comment POSIX.1
398 @item _SC_ASYNCHRONOUS_IO
399 Inquire about the parameter corresponding to @code{_POSIX_ASYNCHRONOUS_IO}.
400
401 @comment unistd.h
402 @comment POSIX.1
403 @item _SC_PRIORITIZED_IO
404 Inquire about the parameter corresponding to @code{_POSIX_PRIORITIZED_IO}.
405
406 @comment unistd.h
407 @comment POSIX.1
408 @item _SC_SYNCHRONIZED_IO
409 Inquire about the parameter corresponding to @code{_POSIX_SYNCHRONIZED_IO}.
410
411 @comment unistd.h
412 @comment POSIX.1
413 @item _SC_FSYNC
414 Inquire about the parameter corresponding to @code{_POSIX_FSYNC}.
415
416 @comment unistd.h
417 @comment POSIX.1
418 @item _SC_MAPPED_FILES
419 Inquire about the parameter corresponding to @code{_POSIX_MAPPED_FILES}.
420
421 @comment unistd.h
422 @comment POSIX.1
423 @item _SC_MEMLOCK
424 Inquire about the parameter corresponding to @code{_POSIX_MEMLOCK}.
425
426 @comment unistd.h
427 @comment POSIX.1
428 @item _SC_MEMLOCK_RANGE
429 Inquire about the parameter corresponding to @code{_POSIX_MEMLOCK_RANGE}.
430
431 @comment unistd.h
432 @comment POSIX.1
433 @item _SC_MEMORY_PROTECTION
434 Inquire about the parameter corresponding to @code{_POSIX_MEMORY_PROTECTION}.
435
436 @comment unistd.h
437 @comment POSIX.1
438 @item _SC_MESSAGE_PASSING
439 Inquire about the parameter corresponding to @code{_POSIX_MESSAGE_PASSING}.
440
441 @comment unistd.h
442 @comment POSIX.1
443 @item _SC_SEMAPHORES
444 Inquire about the parameter corresponding to @code{_POSIX_SEMAPHORES}.
445
446 @comment unistd.h
447 @comment POSIX.1
448 @item _SC_SHARED_MEMORY_OBJECTS
449 Inquire about the parameter corresponding to
450 @code{_POSIX_SHARED_MEMORY_OBJECTS}.
451
452 @comment unistd.h
453 @comment POSIX.1
454 @item _SC_AIO_LISTIO_MAX
455 Inquire about the parameter corresponding to @code{_POSIX_AIO_LISTIO_MAX}.
456
457 @comment unistd.h
458 @comment POSIX.1
459 @item _SC_AIO_MAX
460 Inquire about the parameter corresponding to @code{_POSIX_AIO_MAX}.
461
462 @comment unistd.h
463 @comment POSIX.1
464 @item _SC_AIO_PRIO_DELTA_MAX
465 Inquire the value by which a process can decrease its asynchronous I/O
466 priority level from its own scheduling priority.  This corresponds to the
467 run-time invariant value @code{AIO_PRIO_DELTA_MAX}.
468
469 @comment unistd.h
470 @comment POSIX.1
471 @item _SC_DELAYTIMER_MAX
472 Inquire about the parameter corresponding to @code{_POSIX_DELAYTIMER_MAX}.
473
474 @comment unistd.h
475 @comment POSIX.1
476 @item _SC_MQ_OPEN_MAX
477 Inquire about the parameter corresponding to @code{_POSIX_MQ_OPEN_MAX}.
478
479 @comment unistd.h
480 @comment POSIX.1
481 @item _SC_MQ_PRIO_MAX
482 Inquire about the parameter corresponding to @code{_POSIX_MQ_PRIO_MAX}.
483
484 @comment unistd.h
485 @comment POSIX.1
486 @item _SC_RTSIG_MAX
487 Inquire about the parameter corresponding to @code{_POSIX_RTSIG_MAX}.
488
489 @comment unistd.h
490 @comment POSIX.1
491 @item _SC_SEM_NSEMS_MAX
492 Inquire about the parameter corresponding to @code{_POSIX_SEM_NSEMS_MAX}.
493
494 @comment unistd.h
495 @comment POSIX.1
496 @item _SC_SEM_VALUE_MAX
497 Inquire about the parameter corresponding to @code{_POSIX_SEM_VALUE_MAX}.
498
499 @comment unistd.h
500 @comment POSIX.1
501 @item _SC_SIGQUEUE_MAX
502 Inquire about the parameter corresponding to @code{_POSIX_SIGQUEUE_MAX}.
503
504 @comment unistd.h
505 @comment POSIX.1
506 @item _SC_TIMER_MAX
507 Inquire about the parameter corresponding to @code{_POSIX_TIMER_MAX}.
508
509 @comment unistd.h
510 @comment POSIX.1g
511 @item _SC_PII
512 Inquire about the parameter corresponding to @code{_POSIX_PII}.
513
514 @comment unistd.h
515 @comment POSIX.1g
516 @item _SC_PII_XTI
517 Inquire about the parameter corresponding to @code{_POSIX_PII_XTI}.
518
519 @comment unistd.h
520 @comment POSIX.1g
521 @item _SC_PII_SOCKET
522 Inquire about the parameter corresponding to @code{_POSIX_PII_SOCKET}.
523
524 @comment unistd.h
525 @comment POSIX.1g
526 @item _SC_PII_INTERNET
527 Inquire about the parameter corresponding to @code{_POSIX_PII_INTERNET}.
528
529 @comment unistd.h
530 @comment POSIX.1g
531 @item _SC_PII_OSI
532 Inquire about the parameter corresponding to @code{_POSIX_PII_OSI}.
533
534 @comment unistd.h
535 @comment POSIX.1g
536 @item _SC_SELECT
537 Inquire about the parameter corresponding to @code{_POSIX_SELECT}.
538
539 @comment unistd.h
540 @comment POSIX.1g
541 @item _SC_UIO_MAXIOV
542 Inquire about the parameter corresponding to @code{_POSIX_UIO_MAXIOV}.
543
544 @comment unistd.h
545 @comment POSIX.1g
546 @item _SC_PII_INTERNET_STREAM
547 Inquire about the parameter corresponding to @code{_POSIX_PII_INTERNET_STREAM}.
548
549 @comment unistd.h
550 @comment POSIX.1g
551 @item _SC_PII_INTERNET_DGRAM
552 Inquire about the parameter corresponding to @code{_POSIX_PII_INTERNET_DGRAM}.
553
554 @comment unistd.h
555 @comment POSIX.1g
556 @item _SC_PII_OSI_COTS
557 Inquire about the parameter corresponding to @code{_POSIX_PII_OSI_COTS}.
558
559 @comment unistd.h
560 @comment POSIX.1g
561 @item _SC_PII_OSI_CLTS
562 Inquire about the parameter corresponding to @code{_POSIX_PII_OSI_CLTS}.
563
564 @comment unistd.h
565 @comment POSIX.1g
566 @item _SC_PII_OSI_M
567 Inquire about the parameter corresponding to @code{_POSIX_PII_OSI_M}.
568
569 @comment unistd.h
570 @comment POSIX.1g
571 @item _SC_T_IOV_MAX
572 Inquire the value of the value associated with the @code{T_IOV_MAX}
573 variable.
574
575 @comment unistd.h
576 @comment POSIX.1
577 @item _SC_THREADS
578 Inquire about the parameter corresponding to @code{_POSIX_THREADS}.
579
580 @comment unistd.h
581 @comment POSIX.1
582 @item _SC_THREAD_SAFE_FUNCTIONS
583 Inquire about the parameter corresponding to
584 @code{_POSIX_THREAD_SAFE_FUNCTIONS}.
585
586 @comment unistd.h
587 @comment POSIX.1
588 @item _SC_GETGR_R_SIZE_MAX
589 Inquire about the parameter corresponding to @code{_POSIX_GETGR_R_SIZE_MAX}.
590
591 @comment unistd.h
592 @comment POSIX.1
593 @item _SC_GETPW_R_SIZE_MAX
594 Inquire about the parameter corresponding to @code{_POSIX_GETPW_R_SIZE_MAX}.
595
596 @comment unistd.h
597 @comment POSIX.1
598 @item _SC_LOGIN_NAME_MAX
599 Inquire about the parameter corresponding to @code{_POSIX_LOGIN_NAME_MAX}.
600
601 @comment unistd.h
602 @comment POSIX.1
603 @item _SC_TTY_NAME_MAX
604 Inquire about the parameter corresponding to @code{_POSIX_TTY_NAME_MAX}.
605
606 @comment unistd.h
607 @comment POSIX.1
608 @item _SC_THREAD_DESTRUCTOR_ITERATIONS
609 Inquire about the parameter corresponding to
610 @code{_POSIX_THREAD_DESTRUCTOR_ITERATIONS}.
611
612 @comment unistd.h
613 @comment POSIX.1
614 @item _SC_THREAD_KEYS_MAX
615 Inquire about the parameter corresponding to @code{_POSIX_THREAD_KEYS_MAX}.
616
617 @comment unistd.h
618 @comment POSIX.1
619 @item _SC_THREAD_STACK_MIN
620 Inquire about the parameter corresponding to @code{_POSIX_THREAD_STACK_MIN}.
621
622 @comment unistd.h
623 @comment POSIX.1
624 @item _SC_THREAD_THREADS_MAX
625 Inquire about the parameter corresponding to @code{_POSIX_THREAD_THREADS_MAX}.
626
627 @comment unistd.h
628 @comment POSIX.1
629 @item _SC_THREAD_ATTR_STACKADDR
630 Inquire about the parameter corresponding to
631 @code{_POSIX_THREAD_ATTR_STACKADDR}.
632
633 @comment unistd.h
634 @comment POSIX.1
635 @item _SC_THREAD_ATTR_STACKSIZE
636 Inquire about the parameter corresponding to
637 @code{_POSIX_THREAD_ATTR_STACKSIZE}.
638
639 @comment unistd.h
640 @comment POSIX.1
641 @item _SC_THREAD_PRIORITY_SCHEDULING
642 Inquire about the parameter corresponding to
643 @code{_POSIX_THREAD_PRIORITY_SCHEDULING}.
644
645 @comment unistd.h
646 @comment POSIX.1
647 @item _SC_THREAD_PRIO_INHERIT
648 Inquire about the parameter corresponding to @code{_POSIX_THREAD_PRIO_INHERIT}.
649
650 @comment unistd.h
651 @comment POSIX.1
652 @item _SC_THREAD_PRIO_PROTECT
653 Inquire about the parameter corresponding to @code{_POSIX_THREAD_PRIO_PROTECT}.
654
655 @comment unistd.h
656 @comment POSIX.1
657 @item _SC_THREAD_PROCESS_SHARED
658 Inquire about the parameter corresponding to
659 @code{_POSIX_THREAD_PROCESS_SHARED}.
660
661 @comment unistd.h
662 @comment POSIX.2
663 @item _SC_2_C_DEV
664 Inquire about whether the system has the POSIX.2 C compiler command,
665 @code{c89}.
666
667 @comment unistd.h
668 @comment POSIX.2
669 @item _SC_2_FORT_DEV
670 Inquire about whether the system has the POSIX.2 Fortran compiler
671 command, @code{fort77}.
672
673 @comment unistd.h
674 @comment POSIX.2
675 @item _SC_2_FORT_RUN
676 Inquire about whether the system has the POSIX.2 @code{asa} command to
677 interpret Fortran carriage control.
678
679 @comment unistd.h
680 @comment POSIX.2
681 @item _SC_2_LOCALEDEF
682 Inquire about whether the system has the POSIX.2 @code{localedef}
683 command.
684
685 @comment unistd.h
686 @comment POSIX.2
687 @item _SC_2_SW_DEV
688 Inquire about whether the system has the POSIX.2 commands @code{ar},
689 @code{make}, and @code{strip}.
690
691 @comment unistd.h
692 @comment POSIX.2
693 @item _SC_BC_BASE_MAX
694 Inquire about the maximum value of @code{obase} in the @code{bc}
695 utility.
696
697 @comment unistd.h
698 @comment POSIX.2
699 @item _SC_BC_DIM_MAX
700 Inquire about the maximum size of an array in the @code{bc}
701 utility.
702
703 @comment unistd.h
704 @comment POSIX.2
705 @item _SC_BC_SCALE_MAX
706 Inquire about the maximum value of @code{scale} in the @code{bc}
707 utility.
708
709 @comment unistd.h
710 @comment POSIX.2
711 @item _SC_BC_STRING_MAX
712 Inquire about the maximum size of a string constant in the
713 @code{bc} utility.
714
715 @comment unistd.h
716 @comment POSIX.2
717 @item _SC_COLL_WEIGHTS_MAX
718 Inquire about the maximum number of weights that can necessarily
719 be used in defining the collating sequence for a locale.
720
721 @comment unistd.h
722 @comment POSIX.2
723 @item _SC_EXPR_NEST_MAX
724 Inquire about the maximum number of expressions nested within
725 parentheses when using the @code{expr} utility.
726
727 @comment unistd.h
728 @comment POSIX.2
729 @item _SC_LINE_MAX
730 Inquire about the maximum size of a text line that the POSIX.2 text
731 utilities can handle.
732
733 @comment unistd.h
734 @comment POSIX.2
735 @item _SC_EQUIV_CLASS_MAX
736 Inquire about the maximum number of weights that can be assigned to an
737 entry of the @code{LC_COLLATE} category @samp{order} keyword in a locale
738 definition.  The GNU C library does not presently support locale
739 definitions.
740
741 @comment unistd.h
742 @comment POSIX.2
743 @item _SC_VERSION
744 Inquire about the version number of POSIX.1 that the library and kernel
745 support.
746
747 @comment unistd.h
748 @comment POSIX.2
749 @item _SC_2_VERSION
750 Inquire about the version number of POSIX.2 that the system utilities
751 support.
752
753 @comment unistd.h
754 @comment GNU
755 @item _SC_PAGESIZE
756 Inquire about the virtual memory page size of the machine.
757 @code{getpagesize} returns the same value.
758 @c @xref{XXX getpagesize}. !!! ???
759
760 @comment unistd.h
761 @comment GNU
762 @item _SC_NPROCESSORS_CONF
763 Inquire about number of configured processors.
764
765 @comment unistd.h
766 @comment GNU
767 @item _SC_NPROCESSORS_ONLN
768 Inquire about number of processors online.
769
770 @comment unistd.h
771 @comment GNU
772 @item _SC_PHYS_PAGES
773 Inquire about number of physical pages in the system.
774
775 @comment unistd.h
776 @comment GNU
777 @item _SC_AVPHYS_PAGES
778 Inquire about number of available physical pages in the system.
779
780 @comment unistd.h
781 @comment GNU
782 @item _SC_ATEXIT_MAX
783 Inquire about number of functions which can be registered as termination
784 functions for @code{atexit}; @pxref{Cleanups on Exit}.
785
786 @comment unistd.h
787 @comment X/Open
788 @item _SC_XOPEN_VERSION
789 Inquire about the parameter corresponding to @code{_XOPEN_VERSION}.
790
791 @comment unistd.h
792 @comment X/Open
793 @item _SC_XOPEN_XCU_VERSION
794 Inquire about the parameter corresponding to @code{_XOPEN_XCU_VERSION}.
795
796 @comment unistd.h
797 @comment X/Open
798 @item _SC_XOPEN_UNIX
799 Inquire about the parameter corresponding to @code{_XOPEN_UNIX}.
800
801 @comment unistd.h
802 @comment X/Open
803 @item _SC_XOPEN_CRYPT
804 Inquire about the parameter corresponding to @code{_XOPEN_CRYPT}.
805
806 @comment unistd.h
807 @comment X/Open
808 @item _SC_XOPEN_ENH_I18N
809 Inquire about the parameter corresponding to @code{_XOPEN_ENH_I18N}.
810
811 @comment unistd.h
812 @comment X/Open
813 @item _SC_XOPEN_SHM
814 Inquire about the parameter corresponding to @code{_XOPEN_SHM}.
815
816 @comment unistd.h
817 @comment X/Open
818 @item _SC_XOPEN_XPG2
819 Inquire about the parameter corresponding to @code{_XOPEN_XPG2}.
820
821 @comment unistd.h
822 @comment X/Open
823 @item _SC_XOPEN_XPG3
824 Inquire about the parameter corresponding to @code{_XOPEN_XPG3}.
825
826 @comment unistd.h
827 @comment X/Open
828 @item _SC_XOPEN_XPG4
829 Inquire about the parameter corresponding to @code{_XOPEN_XPG4}.
830
831 @comment unistd.h
832 @comment X/Open
833 @item _SC_CHAR_BIT
834 Inquire about number of bits in a variable of type @code{char}.
835
836 @comment unistd.h
837 @comment X/Open
838 @item _SC_CHAR_MAX
839 Inquire about maximum value which can be stored in a variable of type
840 @code{char}.
841
842 @comment unistd.h
843 @comment X/Open
844 @item _SC_CHAR_MIN
845 Inquire about minimum value which can be stored in a variable of type
846 @code{char}.
847
848 @comment unistd.h
849 @comment X/Open
850 @item _SC_INT_MAX
851 Inquire about maximum value which can be stored in a variable of type
852 @code{int}.
853
854 @comment unistd.h
855 @comment X/Open
856 @item _SC_INT_MIN
857 Inquire about minimum value which can be stored in a variable of type
858 @code{int}.
859
860 @comment unistd.h
861 @comment X/Open
862 @item _SC_LONG_BIT
863 Inquire about number of bits in a variable of type @code{long int}.
864
865 @comment unistd.h
866 @comment X/Open
867 @item _SC_WORD_BIT
868 Inquire about number of bits in a variable of a register word.
869
870 @comment unistd.h
871 @comment X/Open
872 @item _SC_MB_LEN_MAX
873 Inquire the maximum length of a multi-byte representation of a wide
874 character value.
875
876 @comment unistd.h
877 @comment X/Open
878 @item _SC_NZERO
879 Inquire value used to internally represent the zero priority level for
880 the process execution.
881
882 @comment unistd.h
883 @comment X/Open
884 @item SC_SSIZE_MAX
885 Inquire about maximum value which can be stored in a variable of type
886 @code{ssize_t}.
887
888 @comment unistd.h
889 @comment X/Open
890 @item _SC_SCHAR_MAX
891 Inquire about maximum value which can be stored in a variable of type
892 @code{signed char}.
893
894 @comment unistd.h
895 @comment X/Open
896 @item _SC_SCHAR_MIN
897 Inquire about minimum value which can be stored in a variable of type
898 @code{signed char}.
899
900 @comment unistd.h
901 @comment X/Open
902 @item _SC_SHRT_MAX
903 Inquire about maximum value which can be stored in a variable of type
904 @code{short int}.
905
906 @comment unistd.h
907 @comment X/Open
908 @item _SC_SHRT_MIN
909 Inquire about minimum value which can be stored in a variable of type
910 @code{short int}.
911
912 @comment unistd.h
913 @comment X/Open
914 @item _SC_UCHAR_MAX
915 Inquire about maximum value which can be stored in a variable of type
916 @code{unsigned char}.
917
918 @comment unistd.h
919 @comment X/Open
920 @item _SC_UINT_MAX
921 Inquire about maximum value which can be stored in a variable of type
922 @code{unsigned int}.
923
924 @comment unistd.h
925 @comment X/Open
926 @item _SC_ULONG_MAX
927 Inquire about maximum value which can be stored in a variable of type
928 @code{unsigned long int}.
929
930 @comment unistd.h
931 @comment X/Open
932 @item _SC_USHRT_MAX
933 Inquire about maximum value which can be stored in a variable of type
934 @code{unsigned short int}.
935
936 @comment unistd.h
937 @comment X/Open
938 @item _SC_NL_ARGMAX
939 Inquire about the parameter corresponding to @code{NL_ARGMAX}.
940
941 @comment unistd.h
942 @comment X/Open
943 @item _SC_NL_LANGMAX
944 Inquire about the parameter corresponding to @code{NL_LANGMAX}.
945
946 @comment unistd.h
947 @comment X/Open
948 @item _SC_NL_MSGMAX
949 Inquire about the parameter corresponding to @code{NL_MSGMAX}.
950
951 @comment unistd.h
952 @comment X/Open
953 @item _SC_NL_NMAX
954 Inquire about  the parameter corresponding to @code{NL_NMAX}.
955
956 @comment unistd.h
957 @comment X/Open
958 @item _SC_NL_SETMAX
959 Inquire about  the parameter corresponding to @code{NL_SETMAX}.
960
961 @comment unistd.h
962 @comment X/Open
963 @item _SC_NL_TEXTMAX
964 Inquire about  the parameter corresponding to @code{NL_TEXTMAX}.
965 @end table
966
967 @node Examples of Sysconf
968 @subsection Examples of @code{sysconf}
969
970 We recommend that you first test for a macro definition for the
971 parameter you are interested in, and call @code{sysconf} only if the
972 macro is not defined.  For example, here is how to test whether job
973 control is supported:
974
975 @smallexample
976 @group
977 int
978 have_job_control (void)
979 @{
980 #ifdef _POSIX_JOB_CONTROL
981   return 1;
982 #else
983   int value = sysconf (_SC_JOB_CONTROL);
984   if (value < 0)
985     /* @r{If the system is that badly wedged,}
986        @r{there's no use trying to go on.}  */
987     fatal (strerror (errno));
988   return value;
989 #endif
990 @}
991 @end group
992 @end smallexample
993
994 Here is how to get the value of a numeric limit:
995
996 @smallexample
997 int
998 get_child_max ()
999 @{
1000 #ifdef CHILD_MAX
1001   return CHILD_MAX;
1002 #else
1003   int value = sysconf (_SC_CHILD_MAX);
1004   if (value < 0)
1005     fatal (strerror (errno));
1006   return value;
1007 #endif
1008 @}
1009 @end smallexample
1010
1011 @node Minimums
1012 @section Minimum Values for General Capacity Limits
1013
1014 Here are the names for the POSIX minimum upper bounds for the system
1015 limit parameters.  The significance of these values is that you can
1016 safely push to these limits without checking whether the particular
1017 system you are using can go that far.
1018
1019 @table @code
1020 @comment limits.h
1021 @comment POSIX.1
1022 @item _POSIX_AIO_LISTIO_MAX
1023 The most restrictive limit permitted by POSIX for the maximum number of
1024 I/O operations that can be specified in a list I/O call.  The value of
1025 this constant is @code{2}; thus you can add up to two new entries
1026 of the list of outstandard operations.
1027
1028 @comment limits.h
1029 @comment POSIX.1
1030 @item _POSIX_AIO_MAX
1031 The most restrictive limit permitted by POSIX for the maximum number of
1032 outstanding asynchronous I/O operations.  The value of this constant is
1033 @code{1}.  So you cannot expect that you can issue more than one
1034 operation and immediately continue with the normal work, receiving the
1035 notifications asynchronously.
1036
1037 @comment limits.h
1038 @comment POSIX.1
1039 @item _POSIX_ARG_MAX
1040 The value of this macro is the most restrictive limit permitted by POSIX
1041 for the maximum combined length of the @var{argv} and @var{environ}
1042 arguments that can be passed to the @code{exec} functions.
1043 Its value is @code{4096}.
1044
1045 @comment limits.h
1046 @comment POSIX.1
1047 @item _POSIX_CHILD_MAX
1048 The value of this macro is the most restrictive limit permitted by POSIX
1049 for the maximum number of simultaneous processes per real user ID.  Its
1050 value is @code{6}.
1051
1052 @comment limits.h
1053 @comment POSIX.1
1054 @item _POSIX_NGROUPS_MAX
1055 The value of this macro is the most restrictive limit permitted by POSIX
1056 for the maximum number of supplementary group IDs per process.  Its
1057 value is @code{0}.
1058
1059 @comment limits.h
1060 @comment POSIX.1
1061 @item _POSIX_OPEN_MAX
1062 The value of this macro is the most restrictive limit permitted by POSIX
1063 for the maximum number of files that a single process can have open
1064 simultaneously.  Its value is @code{16}.
1065
1066 @comment limits.h
1067 @comment POSIX.1
1068 @item _POSIX_SSIZE_MAX
1069 The value of this macro is the most restrictive limit permitted by POSIX
1070 for the maximum value that can be stored in an object of type
1071 @code{ssize_t}.  Its value is @code{32767}.
1072
1073 @comment limits.h
1074 @comment POSIX.1
1075 @item _POSIX_STREAM_MAX
1076 The value of this macro is the most restrictive limit permitted by POSIX
1077 for the maximum number of streams that a single process can have open
1078 simultaneously.  Its value is @code{8}.
1079
1080 @comment limits.h
1081 @comment POSIX.1
1082 @item _POSIX_TZNAME_MAX
1083 The value of this macro is the most restrictive limit permitted by POSIX
1084 for the maximum length of a time zone name.  Its value is @code{3}.
1085
1086 @comment limits.h
1087 @comment POSIX.2
1088 @item _POSIX2_RE_DUP_MAX
1089 The value of this macro is the most restrictive limit permitted by POSIX
1090 for the numbers used in the @samp{\@{@var{min},@var{max}\@}} construct
1091 in a regular expression.  Its value is @code{255}.
1092 @end table
1093
1094 @node Limits for Files
1095 @section Limits on File System Capacity
1096
1097 The POSIX.1 standard specifies a number of parameters that describe the
1098 limitations of the file system.  It's possible for the system to have a
1099 fixed, uniform limit for a parameter, but this isn't the usual case.  On
1100 most systems, it's possible for different file systems (and, for some
1101 parameters, even different files) to have different maximum limits.  For
1102 example, this is very likely if you use NFS to mount some of the file
1103 systems from other machines.
1104
1105 @pindex limits.h
1106 Each of the following macros is defined in @file{limits.h} only if the
1107 system has a fixed, uniform limit for the parameter in question.  If the
1108 system allows different file systems or files to have different limits,
1109 then the macro is undefined; use @code{pathconf} or @code{fpathconf} to
1110 find out the limit that applies to a particular file.  @xref{Pathconf}.
1111
1112 Each parameter also has another macro, with a name starting with
1113 @samp{_POSIX}, which gives the lowest value that the limit is allowed to
1114 have on @emph{any} POSIX system.  @xref{File Minimums}.
1115
1116 @cindex limits, link count of files
1117 @comment limits.h
1118 @comment POSIX.1
1119 @deftypevr Macro int LINK_MAX
1120 The uniform system limit (if any) for the number of names for a given
1121 file.  @xref{Hard Links}.
1122 @end deftypevr
1123
1124 @cindex limits, terminal input queue
1125 @comment limits.h
1126 @comment POSIX.1
1127 @deftypevr Macro int MAX_CANON
1128 The uniform system limit (if any) for the amount of text in a line of
1129 input when input editing is enabled.  @xref{Canonical or Not}.
1130 @end deftypevr
1131
1132 @comment limits.h
1133 @comment POSIX.1
1134 @deftypevr Macro int MAX_INPUT
1135 The uniform system limit (if any) for the total number of characters
1136 typed ahead as input.  @xref{I/O Queues}.
1137 @end deftypevr
1138
1139 @cindex limits, file name length
1140 @comment limits.h
1141 @comment POSIX.1
1142 @deftypevr Macro int NAME_MAX
1143 The uniform system limit (if any) for the length of a file name component.
1144 @end deftypevr
1145
1146 @comment limits.h
1147 @comment POSIX.1
1148 @deftypevr Macro int PATH_MAX
1149 The uniform system limit (if any) for the length of an entire file name (that
1150 is, the argument given to system calls such as @code{open}).
1151 @end deftypevr
1152
1153 @cindex limits, pipe buffer size
1154 @comment limits.h
1155 @comment POSIX.1
1156 @deftypevr Macro int PIPE_BUF
1157 The uniform system limit (if any) for the number of bytes that can be
1158 written atomically to a pipe.  If multiple processes are writing to the
1159 same pipe simultaneously, output from different processes might be
1160 interleaved in chunks of this size.  @xref{Pipes and FIFOs}.
1161 @end deftypevr
1162
1163 These are alternative macro names for some of the same information.
1164
1165 @comment dirent.h
1166 @comment BSD
1167 @deftypevr Macro int MAXNAMLEN
1168 This is the BSD name for @code{NAME_MAX}.  It is defined in
1169 @file{dirent.h}.
1170 @end deftypevr
1171
1172 @comment stdio.h
1173 @comment ISO
1174 @deftypevr Macro int FILENAME_MAX
1175 The value of this macro is an integer constant expression that
1176 represents the maximum length of a file name string.  It is defined in
1177 @file{stdio.h}.
1178
1179 Unlike @code{PATH_MAX}, this macro is defined even if there is no actual
1180 limit imposed.  In such a case, its value is typically a very large
1181 number.  @strong{This is always the case on the GNU system.}
1182
1183 @strong{Usage Note:} Don't use @code{FILENAME_MAX} as the size of an
1184 array in which to store a file name!  You can't possibly make an array
1185 that big!  Use dynamic allocation (@pxref{Memory Allocation}) instead.
1186 @end deftypevr
1187
1188 @node Options for Files
1189 @section Optional Features in File Support
1190
1191 POSIX defines certain system-specific options in the system calls for
1192 operating on files.  Some systems support these options and others do
1193 not.  Since these options are provided in the kernel, not in the
1194 library, simply using the GNU C library does not guarantee any of these
1195 features is supported; it depends on the system you are using.  They can
1196 also vary between file systems on a single machine.
1197
1198 @pindex unistd.h
1199 This section describes the macros you can test to determine whether a
1200 particular option is supported on your machine.  If a given macro is
1201 defined in @file{unistd.h}, then its value says whether the
1202 corresponding feature is supported.  (A value of @code{-1} indicates no;
1203 any other value indicates yes.)  If the macro is undefined, it means
1204 particular files may or may not support the feature.
1205
1206 Since all the machines that support the GNU C library also support NFS,
1207 one can never make a general statement about whether all file systems
1208 support the @code{_POSIX_CHOWN_RESTRICTED} and @code{_POSIX_NO_TRUNC}
1209 features.  So these names are never defined as macros in the GNU C
1210 library.
1211
1212 @comment unistd.h
1213 @comment POSIX.1
1214 @deftypevr Macro int _POSIX_CHOWN_RESTRICTED
1215 If this option is in effect, the @code{chown} function is restricted so
1216 that the only changes permitted to nonprivileged processes is to change
1217 the group owner of a file to either be the effective group ID of the
1218 process, or one of its supplementary group IDs.  @xref{File Owner}.
1219 @end deftypevr
1220
1221 @comment unistd.h
1222 @comment POSIX.1
1223 @deftypevr Macro int _POSIX_NO_TRUNC
1224 If this option is in effect, file name components longer than
1225 @code{NAME_MAX} generate an @code{ENAMETOOLONG} error.  Otherwise, file
1226 name components that are too long are silently truncated.
1227 @end deftypevr
1228
1229 @comment unistd.h
1230 @comment POSIX.1
1231 @deftypevr Macro {unsigned char} _POSIX_VDISABLE
1232 This option is only meaningful for files that are terminal devices.
1233 If it is enabled, then handling for special control characters can
1234 be disabled individually.  @xref{Special Characters}.
1235 @end deftypevr
1236
1237 @pindex unistd.h
1238 If one of these macros is undefined, that means that the option might be
1239 in effect for some files and not for others.  To inquire about a
1240 particular file, call @code{pathconf} or @code{fpathconf}.
1241 @xref{Pathconf}.
1242
1243 @node File Minimums
1244 @section Minimum Values for File System Limits
1245
1246 Here are the names for the POSIX minimum upper bounds for some of the
1247 above parameters.  The significance of these values is that you can
1248 safely push to these limits without checking whether the particular
1249 system you are using can go that far.  In most cases GNU systems do not
1250 have these strict limitations.  The actual limit should be requested if
1251 necessary.
1252
1253 @table @code
1254 @comment limits.h
1255 @comment POSIX.1
1256 @item _POSIX_LINK_MAX
1257 The most restrictive limit permitted by POSIX for the maximum value of a
1258 file's link count.  The value of this constant is @code{8}; thus, you
1259 can always make up to eight names for a file without running into a
1260 system limit.
1261
1262 @comment limits.h
1263 @comment POSIX.1
1264 @item _POSIX_MAX_CANON
1265 The most restrictive limit permitted by POSIX for the maximum number of
1266 bytes in a canonical input line from a terminal device.  The value of
1267 this constant is @code{255}.
1268
1269 @comment limits.h
1270 @comment POSIX.1
1271 @item _POSIX_MAX_INPUT
1272 The most restrictive limit permitted by POSIX for the maximum number of
1273 bytes in a terminal device input queue (or typeahead buffer).
1274 @xref{Input Modes}.  The value of this constant is @code{255}.
1275
1276 @comment limits.h
1277 @comment POSIX.1
1278 @item _POSIX_NAME_MAX
1279 The most restrictive limit permitted by POSIX for the maximum number of
1280 bytes in a file name component.  The value of this constant is
1281 @code{14}.
1282
1283 @comment limits.h
1284 @comment POSIX.1
1285 @item _POSIX_PATH_MAX
1286 The most restrictive limit permitted by POSIX for the maximum number of
1287 bytes in a file name.  The value of this constant is @code{255}.
1288
1289 @comment limits.h
1290 @comment POSIX.1
1291 @item _POSIX_PIPE_BUF
1292 The most restrictive limit permitted by POSIX for the maximum number of
1293 bytes that can be written atomically to a pipe.  The value of this
1294 constant is @code{512}.
1295 @end table
1296
1297 @node Pathconf
1298 @section Using @code{pathconf}
1299
1300 When your machine allows different files to have different values for a
1301 file system parameter, you can use the functions in this section to find
1302 out the value that applies to any particular file.
1303
1304 These functions and the associated constants for the @var{parameter}
1305 argument are declared in the header file @file{unistd.h}.
1306
1307 @comment unistd.h
1308 @comment POSIX.1
1309 @deftypefun {long int} pathconf (const char *@var{filename}, int @var{parameter})
1310 This function is used to inquire about the limits that apply to
1311 the file named @var{filename}.
1312
1313 The @var{parameter} argument should be one of the @samp{_PC_} constants
1314 listed below.
1315
1316 The normal return value from @code{pathconf} is the value you requested.
1317 A value of @code{-1} is returned both if the implementation does not
1318 impose a limit, and in case of an error.  In the former case,
1319 @code{errno} is not set, while in the latter case, @code{errno} is set
1320 to indicate the cause of the problem.  So the only way to use this
1321 function robustly is to store @code{0} into @code{errno} just before
1322 calling it.
1323
1324 Besides the usual file name errors (@pxref{File Name Errors}),
1325 the following error condition is defined for this function:
1326
1327 @table @code
1328 @item EINVAL
1329 The value of @var{parameter} is invalid, or the implementation doesn't
1330 support the @var{parameter} for the specific file.
1331 @end table
1332 @end deftypefun
1333
1334 @comment unistd.h
1335 @comment POSIX.1
1336 @deftypefun {long int} fpathconf (int @var{filedes}, int @var{parameter})
1337 This is just like @code{pathconf} except that an open file descriptor
1338 is used to specify the file for which information is requested, instead
1339 of a file name.
1340
1341 The following @code{errno} error conditions are defined for this function:
1342
1343 @table @code
1344 @item EBADF
1345 The @var{filedes} argument is not a valid file descriptor.
1346
1347 @item EINVAL
1348 The value of @var{parameter} is invalid, or the implementation doesn't
1349 support the @var{parameter} for the specific file.
1350 @end table
1351 @end deftypefun
1352
1353 Here are the symbolic constants that you can use as the @var{parameter}
1354 argument to @code{pathconf} and @code{fpathconf}.  The values are all
1355 integer constants.
1356
1357 @table @code
1358 @comment unistd.h
1359 @comment POSIX.1
1360 @item _PC_LINK_MAX
1361 Inquire about the value of @code{LINK_MAX}.
1362
1363 @comment unistd.h
1364 @comment POSIX.1
1365 @item _PC_MAX_CANON
1366 Inquire about the value of @code{MAX_CANON}.
1367
1368 @comment unistd.h
1369 @comment POSIX.1
1370 @item _PC_MAX_INPUT
1371 Inquire about the value of @code{MAX_INPUT}.
1372
1373 @comment unistd.h
1374 @comment POSIX.1
1375 @item _PC_NAME_MAX
1376 Inquire about the value of @code{NAME_MAX}.
1377
1378 @comment unistd.h
1379 @comment POSIX.1
1380 @item _PC_PATH_MAX
1381 Inquire about the value of @code{PATH_MAX}.
1382
1383 @comment unistd.h
1384 @comment POSIX.1
1385 @item _PC_PIPE_BUF
1386 Inquire about the value of @code{PIPE_BUF}.
1387
1388 @comment unistd.h
1389 @comment POSIX.1
1390 @item _PC_CHOWN_RESTRICTED
1391 Inquire about the value of @code{_POSIX_CHOWN_RESTRICTED}.
1392
1393 @comment unistd.h
1394 @comment POSIX.1
1395 @item _PC_NO_TRUNC
1396 Inquire about the value of @code{_POSIX_NO_TRUNC}.
1397
1398 @comment unistd.h
1399 @comment POSIX.1
1400 @item _PC_VDISABLE
1401 Inquire about the value of @code{_POSIX_VDISABLE}.
1402
1403 @comment unistd.h
1404 @comment POSIX.1
1405 @item _PC_SYNC_IO
1406 Inquire about the value of @code{_POSIX_SYNC_IO}.
1407
1408 @comment unistd.h
1409 @comment POSIX.1
1410 @item _PC_ASYNC_IO
1411 Inquire about the value of @code{_POSIX_ASYNC_IO}.
1412
1413 @comment unistd.h
1414 @comment POSIX.1
1415 @item _PC_PRIO_IO
1416 Inquire about the value of @code{_POSIX_PRIO_IO}.
1417
1418 @comment unistd.h
1419 @comment POSIX.1g
1420 @item _PC_SOCK_MAXBUF
1421 Inquire about the value of @code{_POSIX_PIPE_BUF}.
1422 @end table
1423
1424 @node Utility Limits
1425 @section Utility Program Capacity Limits
1426
1427 The POSIX.2 standard specifies certain system limits that you can access
1428 through @code{sysconf} that apply to utility behavior rather than the
1429 behavior of the library or the operating system.
1430
1431 The GNU C library defines macros for these limits, and @code{sysconf}
1432 returns values for them if you ask; but these values convey no
1433 meaningful information.  They are simply the smallest values that
1434 POSIX.2 permits.
1435
1436 @comment limits.h
1437 @comment POSIX.2
1438 @deftypevr Macro int BC_BASE_MAX
1439 The largest value of @code{obase} that the @code{bc} utility is
1440 guaranteed to support.
1441 @end deftypevr
1442
1443 @comment limits.h
1444 @comment POSIX.2
1445 @deftypevr Macro int BC_DIM_MAX
1446 The largest number of elements in one array that the @code{bc} utility
1447 is guaranteed to support.
1448 @end deftypevr
1449
1450 @comment limits.h
1451 @comment POSIX.2
1452 @deftypevr Macro int BC_SCALE_MAX
1453 The largest value of @code{scale} that the @code{bc} utility is
1454 guaranteed to support.
1455 @end deftypevr
1456
1457 @comment limits.h
1458 @comment POSIX.2
1459 @deftypevr Macro int BC_STRING_MAX
1460 The largest number of characters in one string constant that the
1461 @code{bc} utility is guaranteed to support.
1462 @end deftypevr
1463
1464 @comment limits.h
1465 @comment POSIX.2
1466 @deftypevr Macro int COLL_WEIGHTS_MAX
1467 The largest number of weights that can necessarily be used in defining
1468 the collating sequence for a locale.
1469 @end deftypevr
1470
1471 @comment limits.h
1472 @comment POSIX.2
1473 @deftypevr Macro int EXPR_NEST_MAX
1474 The maximum number of expressions that can be nested within parenthesis
1475 by the @code{expr} utility.
1476 @end deftypevr
1477
1478 @comment limits.h
1479 @comment POSIX.2
1480 @deftypevr Macro int LINE_MAX
1481 The largest text line that the text-oriented POSIX.2 utilities can
1482 support.  (If you are using the GNU versions of these utilities, then
1483 there is no actual limit except that imposed by the available virtual
1484 memory, but there is no way that the library can tell you this.)
1485 @end deftypevr
1486
1487 @comment limits.h
1488 @comment POSIX.2
1489 @deftypevr Macro int EQUIV_CLASS_MAX
1490 The maximum number of weights that can be assigned to an entry of the
1491 @code{LC_COLLATE} category @samp{order} keyword in a locale definition.
1492 The GNU C library does not presently support locale definitions.
1493 @end deftypevr
1494
1495 @node Utility Minimums
1496 @section Minimum Values for Utility Limits
1497
1498 @table @code
1499 @comment limits.h
1500 @comment POSIX.2
1501 @item _POSIX2_BC_BASE_MAX
1502 The most restrictive limit permitted by POSIX.2 for the maximum value of
1503 @code{obase} in the @code{bc} utility.  Its value is @code{99}.
1504
1505 @comment limits.h
1506 @comment POSIX.2
1507 @item _POSIX2_BC_DIM_MAX
1508 The most restrictive limit permitted by POSIX.2 for the maximum size of
1509 an array in the @code{bc} utility.  Its value is @code{2048}.
1510
1511 @comment limits.h
1512 @comment POSIX.2
1513 @item _POSIX2_BC_SCALE_MAX
1514 The most restrictive limit permitted by POSIX.2 for the maximum value of
1515 @code{scale} in the @code{bc} utility.  Its value is @code{99}.
1516
1517 @comment limits.h
1518 @comment POSIX.2
1519 @item _POSIX2_BC_STRING_MAX
1520 The most restrictive limit permitted by POSIX.2 for the maximum size of
1521 a string constant in the @code{bc} utility.  Its value is @code{1000}.
1522
1523 @comment limits.h
1524 @comment POSIX.2
1525 @item _POSIX2_COLL_WEIGHTS_MAX
1526 The most restrictive limit permitted by POSIX.2 for the maximum number
1527 of weights that can necessarily be used in defining the collating
1528 sequence for a locale.  Its value is @code{2}.
1529
1530 @comment limits.h
1531 @comment POSIX.2
1532 @item _POSIX2_EXPR_NEST_MAX
1533 The most restrictive limit permitted by POSIX.2 for the maximum number
1534 of expressions nested within parenthesis when using the @code{expr} utility.
1535 Its value is @code{32}.
1536
1537 @comment limits.h
1538 @comment POSIX.2
1539 @item _POSIX2_LINE_MAX
1540 The most restrictive limit permitted by POSIX.2 for the maximum size of
1541 a text line that the text utilities can handle.  Its value is
1542 @code{2048}.
1543
1544 @comment limits.h
1545 @comment POSIX.2
1546 @item _POSIX2_EQUIV_CLASS_MAX
1547 The most restrictive limit permitted by POSIX.2 for the maximum number
1548 of weights that can be assigned to an entry of the @code{LC_COLLATE}
1549 category @samp{order} keyword in a locale definition.  Its value is
1550 @code{2}.  The GNU C library does not presently support locale
1551 definitions.
1552 @end table
1553
1554 @node String Parameters
1555 @section String-Valued Parameters
1556
1557 POSIX.2 defines a way to get string-valued parameters from the operating
1558 system with the function @code{confstr}:
1559
1560 @comment unistd.h
1561 @comment POSIX.2
1562 @deftypefun size_t confstr (int @var{parameter}, char *@var{buf}, size_t @var{len})
1563 This function reads the value of a string-valued system parameter,
1564 storing the string into @var{len} bytes of memory space starting at
1565 @var{buf}.  The @var{parameter} argument should be one of the
1566 @samp{_CS_} symbols listed below.
1567
1568 The normal return value from @code{confstr} is the length of the string
1569 value that you asked for.  If you supply a null pointer for @var{buf},
1570 then @code{confstr} does not try to store the string; it just returns
1571 its length.  A value of @code{0} indicates an error.
1572
1573 If the string you asked for is too long for the buffer (that is, longer
1574 than @code{@var{len} - 1}), then @code{confstr} stores just that much
1575 (leaving room for the terminating null character).  You can tell that
1576 this has happened because @code{confstr} returns a value greater than or
1577 equal to @var{len}.
1578
1579 The following @code{errno} error conditions are defined for this function:
1580
1581 @table @code
1582 @item EINVAL
1583 The value of the @var{parameter} is invalid.
1584 @end table
1585 @end deftypefun
1586
1587 Currently there is just one parameter you can read with @code{confstr}:
1588
1589 @table @code
1590 @comment unistd.h
1591 @comment POSIX.2
1592 @item _CS_PATH
1593 This parameter's value is the recommended default path for searching for
1594 executable files.  This is the path that a user has by default just
1595 after logging in.
1596
1597 @comment unistd.h
1598 @comment Unix98
1599 @item _CS_LFS_CFLAGS
1600 The returned string specifies which additional flags must be given to
1601 the C compiler if a source is compiled using the
1602 @code{_LARGEFILE_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1603
1604 @comment unistd.h
1605 @comment Unix98
1606 @item _CS_LFS_LDFLAGS
1607 The returned string specifies which additional flags must be given to
1608 the linker if a source is compiled using the
1609 @code{_LARGEFILE_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1610
1611 @comment unistd.h
1612 @comment Unix98
1613 @item _CS_LFS_LIBS
1614 The returned string specifies which additional libraries must be linked
1615 to the application if a source is compiled using the
1616 @code{_LARGEFILE_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1617
1618 @comment unistd.h
1619 @comment Unix98
1620 @item _CS_LFS_LINTFLAGS
1621 The returned string specifies which additional flags must be given to
1622 the lint tool if a source is compiled using the
1623 @code{_LARGEFILE_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1624
1625 @comment unistd.h
1626 @comment Unix98
1627 @item _CS_LFS64_CFLAGS
1628 The returned string specifies which additional flags must be given to
1629 the C compiler if a source is compiled using the
1630 @code{_LARGEFILE64_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1631
1632 @comment unistd.h
1633 @comment Unix98
1634 @item _CS_LFS64_LDFLAGS
1635 The returned string specifies which additional flags must be given to
1636 the linker if a source is compiled using the
1637 @code{_LARGEFILE64_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1638
1639 @comment unistd.h
1640 @comment Unix98
1641 @item _CS_LFS64_LIBS
1642 The returned string specifies which additional libraries must be linked
1643 to the application if a source is compiled using the
1644 @code{_LARGEFILE64_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1645
1646 @comment unistd.h
1647 @comment Unix98
1648 @item _CS_LFS64_LINTFLAGS
1649 The returned string specifies which additional flags must be given to
1650 the lint tool if a source is compiled using the
1651 @code{_LARGEFILE64_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1652 @end table
1653
1654 The way to use @code{confstr} without any arbitrary limit on string size
1655 is to call it twice: first call it to get the length, allocate the
1656 buffer accordingly, and then call @code{confstr} again to fill the
1657 buffer, like this:
1658
1659 @smallexample
1660 @group
1661 char *
1662 get_default_path (void)
1663 @{
1664   size_t len = confstr (_CS_PATH, NULL, 0);
1665   char *buffer = (char *) xmalloc (len);
1666
1667   if (confstr (_CS_PATH, buf, len + 1) == 0)
1668     @{
1669       free (buffer);
1670       return NULL;
1671     @}
1672
1673   return buffer;
1674 @}
1675 @end group
1676 @end smallexample