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