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