1 @c This node must have no next pointer.
2 @node System Configuration, , System Information, Top
3 @c %MENU% Parameters describing operating system limits
4 @chapter System Configuration Parameters
6 The functions and macros listed in this chapter give information about
7 configuration parameters of the operating system---for example, capacity
8 limits, presence of optional POSIX features, and the default path for
9 executable files (@pxref{String Parameters}).
12 * General Limits:: Constants and functions that describe
13 various process-related limits that have
14 one uniform value for any given machine.
15 * System Options:: Optional POSIX features.
16 * Version Supported:: Version numbers of POSIX.1 and POSIX.2.
17 * Sysconf:: Getting specific configuration values
18 of general limits and system options.
19 * Minimums:: Minimum values for general limits.
21 * Limits for Files:: Size limitations that pertain to individual files.
22 These can vary between file systems
23 or even from file to file.
24 * Options for Files:: Optional features that some files may support.
25 * File Minimums:: Minimum values for file limits.
26 * Pathconf:: Getting the limit values for a particular file.
28 * Utility Limits:: Capacity limits of some POSIX.2 utility programs.
29 * Utility Minimums:: Minimum allowable values of those limits.
31 * String Parameters:: Getting the default search path.
35 @section General Capacity Limits
36 @cindex POSIX capacity limits
38 @cindex capacity limits, POSIX
40 The POSIX.1 and POSIX.2 standards specify a number of parameters that
41 describe capacity limitations of the system. These limits can be fixed
42 constants for a given operating system, or they can vary from machine to
43 machine. For example, some limit values may be configurable by the
44 system administrator, either at run time or by rebuilding the kernel,
45 and this should not require recompiling application programs.
48 Each of the following limit parameters has a macro that is defined in
49 @file{limits.h} only if the system has a fixed, uniform limit for the
50 parameter in question. If the system allows different file systems or
51 files to have different limits, then the macro is undefined; use
52 @code{sysconf} to find out the limit that applies at a particular time
53 on a particular machine. @xref{Sysconf}.
55 Each of these parameters also has another macro, with a name starting
56 with @samp{_POSIX}, which gives the lowest value that the limit is
57 allowed to have on @emph{any} POSIX system. @xref{Minimums}.
59 @cindex limits, program argument size
62 @deftypevr Macro int ARG_MAX
63 If defined, the unvarying maximum combined length of the @var{argv} and
64 @var{environ} arguments that can be passed to the @code{exec} functions.
67 @cindex limits, number of processes
70 @deftypevr Macro int CHILD_MAX
71 If defined, the unvarying maximum number of processes that can exist
72 with the same real user ID at any one time. In BSD and GNU, this is
73 controlled by the @code{RLIMIT_NPROC} resource limit; @pxref{Limits on
77 @cindex limits, number of open files
80 @deftypevr Macro int OPEN_MAX
81 If defined, the unvarying maximum number of files that a single process
82 can have open simultaneously. In BSD and GNU, this is controlled
83 by the @code{RLIMIT_NOFILE} resource limit; @pxref{Limits on Resources}.
88 @deftypevr Macro int STREAM_MAX
89 If defined, the unvarying maximum number of streams that a single
90 process can have open simultaneously. @xref{Opening Streams}.
93 @cindex limits, time zone name length
96 @deftypevr Macro int TZNAME_MAX
97 If defined, the unvarying maximum length of a time zone name.
98 @xref{Time Zone Functions}.
101 These limit macros are always defined in @file{limits.h}.
103 @cindex limits, number of supplementary group IDs
106 @deftypevr Macro int NGROUPS_MAX
107 The maximum number of supplementary group IDs that one process can have.
109 The value of this macro is actually a lower bound for the maximum. That
110 is, you can count on being able to have that many supplementary group
111 IDs, but a particular machine might let you have even more. You can use
112 @code{sysconf} to see whether a particular machine will let you have
113 more (@pxref{Sysconf}).
118 @deftypevr Macro int SSIZE_MAX
119 The largest value that can fit in an object of type @code{ssize_t}.
120 Effectively, this is the limit on the number of bytes that can be read
121 or written in a single operation.
123 This macro is defined in all POSIX systems because this limit is never
129 @deftypevr Macro int RE_DUP_MAX
130 The largest number of repetitions you are guaranteed is allowed in the
131 construct @samp{\@{@var{min},@var{max}\@}} in a regular expression.
133 The value of this macro is actually a lower bound for the maximum. That
134 is, you can count on being able to have that many repetitions, but a
135 particular machine might let you have even more. You can use
136 @code{sysconf} to see whether a particular machine will let you have
137 more (@pxref{Sysconf}). And even the value that @code{sysconf} tells
138 you is just a lower bound---larger values might work.
140 This macro is defined in all POSIX.2 systems, because POSIX.2 says it
141 should always be defined even if there is no specific imposed limit.
145 @section Overall System Options
146 @cindex POSIX optional features
147 @cindex optional POSIX features
149 POSIX defines certain system-specific options that not all POSIX systems
150 support. Since these options are provided in the kernel, not in the
151 library, simply using the GNU C library does not guarantee any of these
152 features is supported; it depends on the system you are using.
155 You can test for the availability of a given option using the macros in
156 this section, together with the function @code{sysconf}. The macros are
157 defined only if you include @file{unistd.h}.
159 For the following macros, if the macro is defined in @file{unistd.h},
160 then the option is supported. Otherwise, the option may or may not be
161 supported; use @code{sysconf} to find out. @xref{Sysconf}.
165 @deftypevr Macro int _POSIX_JOB_CONTROL
166 If this symbol is defined, it indicates that the system supports job
167 control. Otherwise, the implementation behaves as if all processes
168 within a session belong to a single process group. @xref{Job Control}.
173 @deftypevr Macro int _POSIX_SAVED_IDS
174 If this symbol is defined, it indicates that the system remembers the
175 effective user and group IDs of a process before it executes an
176 executable file with the set-user-ID or set-group-ID bits set, and that
177 explicitly changing the effective user or group IDs back to these values
178 is permitted. If this option is not defined, then if a nonprivileged
179 process changes its effective user or group ID to the real user or group
180 ID of the process, it can't change it back again. @xref{Enable/Disable
184 For the following macros, if the macro is defined in @file{unistd.h},
185 then its value indicates whether the option is supported. A value of
186 @code{-1} means no, and any other value means yes. If the macro is not
187 defined, then the option may or may not be supported; use @code{sysconf}
188 to find out. @xref{Sysconf}.
192 @deftypevr Macro int _POSIX2_C_DEV
193 If this symbol is defined, it indicates that the system has the POSIX.2
194 C compiler command, @code{c89}. The GNU C library always defines this
195 as @code{1}, on the assumption that you would not have installed it if
196 you didn't have a C compiler.
201 @deftypevr Macro int _POSIX2_FORT_DEV
202 If this symbol is defined, it indicates that the system has the POSIX.2
203 Fortran compiler command, @code{fort77}. The GNU C library never
204 defines this, because we don't know what the system has.
209 @deftypevr Macro int _POSIX2_FORT_RUN
210 If this symbol is defined, it indicates that the system has the POSIX.2
211 @code{asa} command to interpret Fortran carriage control. The GNU C
212 library never defines this, because we don't know what the system has.
217 @deftypevr Macro int _POSIX2_LOCALEDEF
218 If this symbol is defined, it indicates that the system has the POSIX.2
219 @code{localedef} command. The GNU C library never defines this, because
220 we don't know what the system has.
225 @deftypevr Macro int _POSIX2_SW_DEV
226 If this symbol is defined, it indicates that the system has the POSIX.2
227 commands @code{ar}, @code{make}, and @code{strip}. The GNU C library
228 always defines this as @code{1}, on the assumption that you had to have
229 @code{ar} and @code{make} to install the library, and it's unlikely that
230 @code{strip} would be absent when those are present.
233 @node Version Supported
234 @section Which Version of POSIX is Supported
238 @deftypevr Macro {long int} _POSIX_VERSION
239 This constant represents the version of the POSIX.1 standard to which
240 the implementation conforms. For an implementation conforming to the
241 1995 POSIX.1 standard, the value is the integer @code{199506L}.
243 @code{_POSIX_VERSION} is always defined (in @file{unistd.h}) in any
246 @strong{Usage Note:} Don't try to test whether the system supports POSIX
247 by including @file{unistd.h} and then checking whether
248 @code{_POSIX_VERSION} is defined. On a non-POSIX system, this will
249 probably fail because there is no @file{unistd.h}. We do not know of
250 @emph{any} way you can reliably test at compilation time whether your
251 target system supports POSIX or whether @file{unistd.h} exists.
253 The GNU C compiler predefines the symbol @code{__POSIX__} if the target
254 system is a POSIX system. Provided you do not use any other compilers
255 on POSIX systems, testing @code{defined (__POSIX__)} will reliably
261 @deftypevr Macro {long int} _POSIX2_C_VERSION
262 This constant represents the version of the POSIX.2 standard which the
263 library and system kernel support. We don't know what value this will
264 be for the first version of the POSIX.2 standard, because the value is
265 based on the year and month in which the standard is officially adopted.
267 The value of this symbol says nothing about the utilities installed on
270 @strong{Usage Note:} You can use this macro to tell whether a POSIX.1
271 system library supports POSIX.2 as well. Any POSIX.1 system contains
272 @file{unistd.h}, so include that file and then test @code{defined
273 (_POSIX2_C_VERSION)}.
277 @section Using @code{sysconf}
279 When your system has configurable system limits, you can use the
280 @code{sysconf} function to find out the value that applies to any
281 particular machine. The function and the associated @var{parameter}
282 constants are declared in the header file @file{unistd.h}.
285 * Sysconf Definition:: Detailed specifications of @code{sysconf}.
286 * Constants for Sysconf:: The list of parameters @code{sysconf} can read.
287 * Examples of Sysconf:: How to use @code{sysconf} and the parameter
288 macros properly together.
291 @node Sysconf Definition
292 @subsection Definition of @code{sysconf}
296 @deftypefun {long int} sysconf (int @var{parameter})
297 This function is used to inquire about runtime system parameters. The
298 @var{parameter} argument should be one of the @samp{_SC_} symbols listed
301 The normal return value from @code{sysconf} is the value you requested.
302 A value of @code{-1} is returned both if the implementation does not
303 impose a limit, and in case of an error.
305 The following @code{errno} error conditions are defined for this function:
309 The value of the @var{parameter} is invalid.
313 @node Constants for Sysconf
314 @subsection Constants for @code{sysconf} Parameters
316 Here are the symbolic constants for use as the @var{parameter} argument
317 to @code{sysconf}. The values are all integer constants (more
318 specifically, enumeration type values).
324 Inquire about the parameter corresponding to @code{ARG_MAX}.
329 Inquire about the parameter corresponding to @code{CHILD_MAX}.
334 Inquire about the parameter corresponding to @code{OPEN_MAX}.
339 Inquire about the parameter corresponding to @code{STREAM_MAX}.
344 Inquire about the parameter corresponding to @code{TZNAME_MAX}.
348 @item _SC_NGROUPS_MAX
349 Inquire about the parameter corresponding to @code{NGROUPS_MAX}.
353 @item _SC_JOB_CONTROL
354 Inquire about the parameter corresponding to @code{_POSIX_JOB_CONTROL}.
359 Inquire about the parameter corresponding to @code{_POSIX_SAVED_IDS}.
364 Inquire about the parameter corresponding to @code{_POSIX_VERSION}.
369 Inquire about the parameter corresponding to @code{CLOCKS_PER_SEC};
370 @pxref{Basic CPU Time}.
374 @item _SC_CHARCLASS_NAME_MAX
375 Inquire about the parameter corresponding to maximal length allowed for
376 a character class name in an extended locale specification. These
377 extensions are not yet standardized and so this option is not standardized
382 @item _SC_REALTIME_SIGNALS
383 Inquire about the parameter corresponding to @code{_POSIX_REALTIME_SIGNALS}.
387 @item _SC_PRIORITY_SCHEDULING
388 Inquire about the parameter corresponding to @code{_POSIX_PRIORITY_SCHEDULING}.
393 Inquire about the parameter corresponding to @code{_POSIX_TIMERS}.
397 @item _SC_ASYNCHRONOUS_IO
398 Inquire about the parameter corresponding to @code{_POSIX_ASYNCHRONOUS_IO}.
402 @item _SC_PRIORITIZED_IO
403 Inquire about the parameter corresponding to @code{_POSIX_PRIORITIZED_IO}.
407 @item _SC_SYNCHRONIZED_IO
408 Inquire about the parameter corresponding to @code{_POSIX_SYNCHRONIZED_IO}.
413 Inquire about the parameter corresponding to @code{_POSIX_FSYNC}.
417 @item _SC_MAPPED_FILES
418 Inquire about the parameter corresponding to @code{_POSIX_MAPPED_FILES}.
423 Inquire about the parameter corresponding to @code{_POSIX_MEMLOCK}.
427 @item _SC_MEMLOCK_RANGE
428 Inquire about the parameter corresponding to @code{_POSIX_MEMLOCK_RANGE}.
432 @item _SC_MEMORY_PROTECTION
433 Inquire about the parameter corresponding to @code{_POSIX_MEMORY_PROTECTION}.
437 @item _SC_MESSAGE_PASSING
438 Inquire about the parameter corresponding to @code{_POSIX_MESSAGE_PASSING}.
443 Inquire about the parameter corresponding to @code{_POSIX_SEMAPHORES}.
447 @item _SC_SHARED_MEMORY_OBJECTS
448 Inquire about the parameter corresponding to
449 @code{_POSIX_SHARED_MEMORY_OBJECTS}.
453 @item _SC_AIO_LISTIO_MAX
454 Inquire about the parameter corresponding to @code{_POSIX_AIO_LISTIO_MAX}.
459 Inquire about the parameter corresponding to @code{_POSIX_AIO_MAX}.
463 @item _SC_AIO_PRIO_DELTA_MAX
464 Inquire the value by which a process can decrease its asynchronous I/O
465 priority level from its own scheduling priority. This corresponds to the
466 run-time invariant value @code{AIO_PRIO_DELTA_MAX}.
470 @item _SC_DELAYTIMER_MAX
471 Inquire about the parameter corresponding to @code{_POSIX_DELAYTIMER_MAX}.
475 @item _SC_MQ_OPEN_MAX
476 Inquire about the parameter corresponding to @code{_POSIX_MQ_OPEN_MAX}.
480 @item _SC_MQ_PRIO_MAX
481 Inquire about the parameter corresponding to @code{_POSIX_MQ_PRIO_MAX}.
486 Inquire about the parameter corresponding to @code{_POSIX_RTSIG_MAX}.
490 @item _SC_SEM_NSEMS_MAX
491 Inquire about the parameter corresponding to @code{_POSIX_SEM_NSEMS_MAX}.
495 @item _SC_SEM_VALUE_MAX
496 Inquire about the parameter corresponding to @code{_POSIX_SEM_VALUE_MAX}.
500 @item _SC_SIGQUEUE_MAX
501 Inquire about the parameter corresponding to @code{_POSIX_SIGQUEUE_MAX}.
506 Inquire about the parameter corresponding to @code{_POSIX_TIMER_MAX}.
511 Inquire about the parameter corresponding to @code{_POSIX_PII}.
516 Inquire about the parameter corresponding to @code{_POSIX_PII_XTI}.
521 Inquire about the parameter corresponding to @code{_POSIX_PII_SOCKET}.
525 @item _SC_PII_INTERNET
526 Inquire about the parameter corresponding to @code{_POSIX_PII_INTERNET}.
531 Inquire about the parameter corresponding to @code{_POSIX_PII_OSI}.
536 Inquire about the parameter corresponding to @code{_POSIX_SELECT}.
541 Inquire about the parameter corresponding to @code{_POSIX_UIO_MAXIOV}.
545 @item _SC_PII_INTERNET_STREAM
546 Inquire about the parameter corresponding to @code{_POSIX_PII_INTERNET_STREAM}.
550 @item _SC_PII_INTERNET_DGRAM
551 Inquire about the parameter corresponding to @code{_POSIX_PII_INTERNET_DGRAM}.
555 @item _SC_PII_OSI_COTS
556 Inquire about the parameter corresponding to @code{_POSIX_PII_OSI_COTS}.
560 @item _SC_PII_OSI_CLTS
561 Inquire about the parameter corresponding to @code{_POSIX_PII_OSI_CLTS}.
566 Inquire about the parameter corresponding to @code{_POSIX_PII_OSI_M}.
571 Inquire the value of the value associated with the @code{T_IOV_MAX}
577 Inquire about the parameter corresponding to @code{_POSIX_THREADS}.
581 @item _SC_THREAD_SAFE_FUNCTIONS
582 Inquire about the parameter corresponding to
583 @code{_POSIX_THREAD_SAFE_FUNCTIONS}.
587 @item _SC_GETGR_R_SIZE_MAX
588 Inquire about the parameter corresponding to @code{_POSIX_GETGR_R_SIZE_MAX}.
592 @item _SC_GETPW_R_SIZE_MAX
593 Inquire about the parameter corresponding to @code{_POSIX_GETPW_R_SIZE_MAX}.
597 @item _SC_LOGIN_NAME_MAX
598 Inquire about the parameter corresponding to @code{_POSIX_LOGIN_NAME_MAX}.
602 @item _SC_TTY_NAME_MAX
603 Inquire about the parameter corresponding to @code{_POSIX_TTY_NAME_MAX}.
607 @item _SC_THREAD_DESTRUCTOR_ITERATIONS
608 Inquire about the parameter corresponding to
609 @code{_POSIX_THREAD_DESTRUCTOR_ITERATIONS}.
613 @item _SC_THREAD_KEYS_MAX
614 Inquire about the parameter corresponding to @code{_POSIX_THREAD_KEYS_MAX}.
618 @item _SC_THREAD_STACK_MIN
619 Inquire about the parameter corresponding to @code{_POSIX_THREAD_STACK_MIN}.
623 @item _SC_THREAD_THREADS_MAX
624 Inquire about the parameter corresponding to @code{_POSIX_THREAD_THREADS_MAX}.
628 @item _SC_THREAD_ATTR_STACKADDR
629 Inquire about the parameter corresponding to
630 @code{_POSIX_THREAD_ATTR_STACKADDR}.
634 @item _SC_THREAD_ATTR_STACKSIZE
635 Inquire about the parameter corresponding to
636 @code{_POSIX_THREAD_ATTR_STACKSIZE}.
640 @item _SC_THREAD_PRIORITY_SCHEDULING
641 Inquire about the parameter corresponding to
642 @code{_POSIX_THREAD_PRIORITY_SCHEDULING}.
646 @item _SC_THREAD_PRIO_INHERIT
647 Inquire about the parameter corresponding to @code{_POSIX_THREAD_PRIO_INHERIT}.
651 @item _SC_THREAD_PRIO_PROTECT
652 Inquire about the parameter corresponding to @code{_POSIX_THREAD_PRIO_PROTECT}.
656 @item _SC_THREAD_PROCESS_SHARED
657 Inquire about the parameter corresponding to
658 @code{_POSIX_THREAD_PROCESS_SHARED}.
663 Inquire about whether the system has the POSIX.2 C compiler command,
669 Inquire about whether the system has the POSIX.2 Fortran compiler
670 command, @code{fort77}.
675 Inquire about whether the system has the POSIX.2 @code{asa} command to
676 interpret Fortran carriage control.
680 @item _SC_2_LOCALEDEF
681 Inquire about whether the system has the POSIX.2 @code{localedef}
687 Inquire about whether the system has the POSIX.2 commands @code{ar},
688 @code{make}, and @code{strip}.
692 @item _SC_BC_BASE_MAX
693 Inquire about the maximum value of @code{obase} in the @code{bc}
699 Inquire about the maximum size of an array in the @code{bc}
704 @item _SC_BC_SCALE_MAX
705 Inquire about the maximum value of @code{scale} in the @code{bc}
710 @item _SC_BC_STRING_MAX
711 Inquire about the maximum size of a string constant in the
716 @item _SC_COLL_WEIGHTS_MAX
717 Inquire about the maximum number of weights that can necessarily
718 be used in defining the collating sequence for a locale.
722 @item _SC_EXPR_NEST_MAX
723 Inquire about the maximum number of expressions nested within
724 parentheses when using the @code{expr} utility.
729 Inquire about the maximum size of a text line that the POSIX.2 text
730 utilities can handle.
734 @item _SC_EQUIV_CLASS_MAX
735 Inquire about the maximum number of weights that can be assigned to an
736 entry of the @code{LC_COLLATE} category @samp{order} keyword in a locale
737 definition. The GNU C library does not presently support locale
743 Inquire about the version number of POSIX.1 that the library and kernel
749 Inquire about the version number of POSIX.2 that the system utilities
755 Inquire about the virtual memory page size of the machine.
756 @code{getpagesize} returns the same value.
757 @c @xref{XXX getpagesize}. !!! ???
761 @item _SC_NPROCESSORS_CONF
762 Inquire about number of configured processors.
766 @item _SC_NPROCESSORS_ONLN
767 Inquire about number of processors online.
772 Inquire about number of physical pages in the system.
776 @item _SC_AVPHYS_PAGES
777 Inquire about number of available physical pages in the system.
782 Inquire about number of functions which can be registered as termination
783 functions for @code{atexit}; @pxref{Cleanups on Exit}.
787 @item _SC_XOPEN_VERSION
788 Inquire about the parameter corresponding to @code{_XOPEN_VERSION}.
792 @item _SC_XOPEN_XCU_VERSION
793 Inquire about the parameter corresponding to @code{_XOPEN_XCU_VERSION}.
798 Inquire about the parameter corresponding to @code{_XOPEN_UNIX}.
802 @item _SC_XOPEN_CRYPT
803 Inquire about the parameter corresponding to @code{_XOPEN_CRYPT}.
807 @item _SC_XOPEN_ENH_I18N
808 Inquire about the parameter corresponding to @code{_XOPEN_ENH_I18N}.
813 Inquire about the parameter corresponding to @code{_XOPEN_SHM}.
818 Inquire about the parameter corresponding to @code{_XOPEN_XPG2}.
823 Inquire about the parameter corresponding to @code{_XOPEN_XPG3}.
828 Inquire about the parameter corresponding to @code{_XOPEN_XPG4}.
833 Inquire about number of bits in a variable of type @code{char}.
838 Inquire about maximum value which can be stored in a variable of type
844 Inquire about minimum value which can be stored in a variable of type
850 Inquire about maximum value which can be stored in a variable of type
856 Inquire about minimum value which can be stored in a variable of type
862 Inquire about number of bits in a variable of type @code{long int}.
867 Inquire about number of bits in a variable of a register word.
872 Inquire the maximum length of a multi-byte representation of a wide
878 Inquire value used to internally represent the zero priority level for
879 the process execution.
884 Inquire about maximum value which can be stored in a variable of type
890 Inquire about maximum value which can be stored in a variable of type
896 Inquire about minimum value which can be stored in a variable of type
902 Inquire about maximum value which can be stored in a variable of type
908 Inquire about minimum value which can be stored in a variable of type
914 Inquire about maximum value which can be stored in a variable of type
915 @code{unsigned char}.
920 Inquire about maximum value which can be stored in a variable of type
926 Inquire about maximum value which can be stored in a variable of type
927 @code{unsigned long int}.
932 Inquire about maximum value which can be stored in a variable of type
933 @code{unsigned short int}.
938 Inquire about the parameter corresponding to @code{NL_ARGMAX}.
943 Inquire about the parameter corresponding to @code{NL_LANGMAX}.
948 Inquire about the parameter corresponding to @code{NL_MSGMAX}.
953 Inquire about the parameter corresponding to @code{NL_NMAX}.
958 Inquire about the parameter corresponding to @code{NL_SETMAX}.
963 Inquire about the parameter corresponding to @code{NL_TEXTMAX}.
966 @node Examples of Sysconf
967 @subsection Examples of @code{sysconf}
969 We recommend that you first test for a macro definition for the
970 parameter you are interested in, and call @code{sysconf} only if the
971 macro is not defined. For example, here is how to test whether job
972 control is supported:
977 have_job_control (void)
979 #ifdef _POSIX_JOB_CONTROL
982 int value = sysconf (_SC_JOB_CONTROL);
984 /* @r{If the system is that badly wedged,}
985 @r{there's no use trying to go on.} */
986 fatal (strerror (errno));
993 Here is how to get the value of a numeric limit:
1002 int value = sysconf (_SC_CHILD_MAX);
1004 fatal (strerror (errno));
1011 @section Minimum Values for General Capacity Limits
1013 Here are the names for the POSIX minimum upper bounds for the system
1014 limit parameters. The significance of these values is that you can
1015 safely push to these limits without checking whether the particular
1016 system you are using can go that far.
1021 @item _POSIX_AIO_LISTIO_MAX
1022 The most restrictive limit permitted by POSIX for the maximum number of
1023 I/O operations that can be specified in a list I/O call. The value of
1024 this constant is @code{2}; thus you can add up to two new entries
1025 of the list of outstandard operations.
1029 @item _POSIX_AIO_MAX
1030 The most restrictive limit permitted by POSIX for the maximum number of
1031 outstanding asynchronous I/O operations. The value of this constant is
1032 @code{1}. So you cannot expect that you can issue more than one
1033 operation and immediately continue with the normal work, receiving the
1034 notifications asynchronously.
1038 @item _POSIX_ARG_MAX
1039 The value of this macro is the most restrictive limit permitted by POSIX
1040 for the maximum combined length of the @var{argv} and @var{environ}
1041 arguments that can be passed to the @code{exec} functions.
1042 Its value is @code{4096}.
1046 @item _POSIX_CHILD_MAX
1047 The value of this macro is the most restrictive limit permitted by POSIX
1048 for the maximum number of simultaneous processes per real user ID. Its
1053 @item _POSIX_NGROUPS_MAX
1054 The value of this macro is the most restrictive limit permitted by POSIX
1055 for the maximum number of supplementary group IDs per process. Its
1060 @item _POSIX_OPEN_MAX
1061 The value of this macro is the most restrictive limit permitted by POSIX
1062 for the maximum number of files that a single process can have open
1063 simultaneously. Its value is @code{16}.
1067 @item _POSIX_SSIZE_MAX
1068 The value of this macro is the most restrictive limit permitted by POSIX
1069 for the maximum value that can be stored in an object of type
1070 @code{ssize_t}. Its value is @code{32767}.
1074 @item _POSIX_STREAM_MAX
1075 The value of this macro is the most restrictive limit permitted by POSIX
1076 for the maximum number of streams that a single process can have open
1077 simultaneously. Its value is @code{8}.
1081 @item _POSIX_TZNAME_MAX
1082 The value of this macro is the most restrictive limit permitted by POSIX
1083 for the maximum length of a time zone name. Its value is @code{3}.
1087 @item _POSIX2_RE_DUP_MAX
1088 The value of this macro is the most restrictive limit permitted by POSIX
1089 for the numbers used in the @samp{\@{@var{min},@var{max}\@}} construct
1090 in a regular expression. Its value is @code{255}.
1093 @node Limits for Files
1094 @section Limits on File System Capacity
1096 The POSIX.1 standard specifies a number of parameters that describe the
1097 limitations of the file system. It's possible for the system to have a
1098 fixed, uniform limit for a parameter, but this isn't the usual case. On
1099 most systems, it's possible for different file systems (and, for some
1100 parameters, even different files) to have different maximum limits. For
1101 example, this is very likely if you use NFS to mount some of the file
1102 systems from other machines.
1105 Each of the following macros is defined in @file{limits.h} only if the
1106 system has a fixed, uniform limit for the parameter in question. If the
1107 system allows different file systems or files to have different limits,
1108 then the macro is undefined; use @code{pathconf} or @code{fpathconf} to
1109 find out the limit that applies to a particular file. @xref{Pathconf}.
1111 Each parameter also has another macro, with a name starting with
1112 @samp{_POSIX}, which gives the lowest value that the limit is allowed to
1113 have on @emph{any} POSIX system. @xref{File Minimums}.
1115 @cindex limits, link count of files
1118 @deftypevr Macro int LINK_MAX
1119 The uniform system limit (if any) for the number of names for a given
1120 file. @xref{Hard Links}.
1123 @cindex limits, terminal input queue
1126 @deftypevr Macro int MAX_CANON
1127 The uniform system limit (if any) for the amount of text in a line of
1128 input when input editing is enabled. @xref{Canonical or Not}.
1133 @deftypevr Macro int MAX_INPUT
1134 The uniform system limit (if any) for the total number of characters
1135 typed ahead as input. @xref{I/O Queues}.
1138 @cindex limits, file name length
1141 @deftypevr Macro int NAME_MAX
1142 The uniform system limit (if any) for the length of a file name component.
1147 @deftypevr Macro int PATH_MAX
1148 The uniform system limit (if any) for the length of an entire file name (that
1149 is, the argument given to system calls such as @code{open}).
1152 @cindex limits, pipe buffer size
1155 @deftypevr Macro int PIPE_BUF
1156 The uniform system limit (if any) for the number of bytes that can be
1157 written atomically to a pipe. If multiple processes are writing to the
1158 same pipe simultaneously, output from different processes might be
1159 interleaved in chunks of this size. @xref{Pipes and FIFOs}.
1162 These are alternative macro names for some of the same information.
1166 @deftypevr Macro int MAXNAMLEN
1167 This is the BSD name for @code{NAME_MAX}. It is defined in
1173 @deftypevr Macro int FILENAME_MAX
1174 The value of this macro is an integer constant expression that
1175 represents the maximum length of a file name string. It is defined in
1178 Unlike @code{PATH_MAX}, this macro is defined even if there is no actual
1179 limit imposed. In such a case, its value is typically a very large
1180 number. @strong{This is always the case on the GNU system.}
1182 @strong{Usage Note:} Don't use @code{FILENAME_MAX} as the size of an
1183 array in which to store a file name! You can't possibly make an array
1184 that big! Use dynamic allocation (@pxref{Memory Allocation}) instead.
1187 @node Options for Files
1188 @section Optional Features in File Support
1190 POSIX defines certain system-specific options in the system calls for
1191 operating on files. Some systems support these options and others do
1192 not. Since these options are provided in the kernel, not in the
1193 library, simply using the GNU C library does not guarantee any of these
1194 features is supported; it depends on the system you are using. They can
1195 also vary between file systems on a single machine.
1198 This section describes the macros you can test to determine whether a
1199 particular option is supported on your machine. If a given macro is
1200 defined in @file{unistd.h}, then its value says whether the
1201 corresponding feature is supported. (A value of @code{-1} indicates no;
1202 any other value indicates yes.) If the macro is undefined, it means
1203 particular files may or may not support the feature.
1205 Since all the machines that support the GNU C library also support NFS,
1206 one can never make a general statement about whether all file systems
1207 support the @code{_POSIX_CHOWN_RESTRICTED} and @code{_POSIX_NO_TRUNC}
1208 features. So these names are never defined as macros in the GNU C
1213 @deftypevr Macro int _POSIX_CHOWN_RESTRICTED
1214 If this option is in effect, the @code{chown} function is restricted so
1215 that the only changes permitted to nonprivileged processes is to change
1216 the group owner of a file to either be the effective group ID of the
1217 process, or one of its supplementary group IDs. @xref{File Owner}.
1222 @deftypevr Macro int _POSIX_NO_TRUNC
1223 If this option is in effect, file name components longer than
1224 @code{NAME_MAX} generate an @code{ENAMETOOLONG} error. Otherwise, file
1225 name components that are too long are silently truncated.
1230 @deftypevr Macro {unsigned char} _POSIX_VDISABLE
1231 This option is only meaningful for files that are terminal devices.
1232 If it is enabled, then handling for special control characters can
1233 be disabled individually. @xref{Special Characters}.
1237 If one of these macros is undefined, that means that the option might be
1238 in effect for some files and not for others. To inquire about a
1239 particular file, call @code{pathconf} or @code{fpathconf}.
1243 @section Minimum Values for File System Limits
1245 Here are the names for the POSIX minimum upper bounds for some of the
1246 above parameters. The significance of these values is that you can
1247 safely push to these limits without checking whether the particular
1248 system you are using can go that far. In most cases GNU systems do not
1249 have these strict limitations. The actual limit should be requested if
1255 @item _POSIX_LINK_MAX
1256 The most restrictive limit permitted by POSIX for the maximum value of a
1257 file's link count. The value of this constant is @code{8}; thus, you
1258 can always make up to eight names for a file without running into a
1263 @item _POSIX_MAX_CANON
1264 The most restrictive limit permitted by POSIX for the maximum number of
1265 bytes in a canonical input line from a terminal device. The value of
1266 this constant is @code{255}.
1270 @item _POSIX_MAX_INPUT
1271 The most restrictive limit permitted by POSIX for the maximum number of
1272 bytes in a terminal device input queue (or typeahead buffer).
1273 @xref{Input Modes}. The value of this constant is @code{255}.
1277 @item _POSIX_NAME_MAX
1278 The most restrictive limit permitted by POSIX for the maximum number of
1279 bytes in a file name component. The value of this constant is
1284 @item _POSIX_PATH_MAX
1285 The most restrictive limit permitted by POSIX for the maximum number of
1286 bytes in a file name. The value of this constant is @code{255}.
1290 @item _POSIX_PIPE_BUF
1291 The most restrictive limit permitted by POSIX for the maximum number of
1292 bytes that can be written atomically to a pipe. The value of this
1293 constant is @code{512}.
1297 @section Using @code{pathconf}
1299 When your machine allows different files to have different values for a
1300 file system parameter, you can use the functions in this section to find
1301 out the value that applies to any particular file.
1303 These functions and the associated constants for the @var{parameter}
1304 argument are declared in the header file @file{unistd.h}.
1308 @deftypefun {long int} pathconf (const char *@var{filename}, int @var{parameter})
1309 This function is used to inquire about the limits that apply to
1310 the file named @var{filename}.
1312 The @var{parameter} argument should be one of the @samp{_PC_} constants
1315 The normal return value from @code{pathconf} is the value you requested.
1316 A value of @code{-1} is returned both if the implementation does not
1317 impose a limit, and in case of an error. In the former case,
1318 @code{errno} is not set, while in the latter case, @code{errno} is set
1319 to indicate the cause of the problem. So the only way to use this
1320 function robustly is to store @code{0} into @code{errno} just before
1323 Besides the usual file name errors (@pxref{File Name Errors}),
1324 the following error condition is defined for this function:
1328 The value of @var{parameter} is invalid, or the implementation doesn't
1329 support the @var{parameter} for the specific file.
1335 @deftypefun {long int} fpathconf (int @var{filedes}, int @var{parameter})
1336 This is just like @code{pathconf} except that an open file descriptor
1337 is used to specify the file for which information is requested, instead
1340 The following @code{errno} error conditions are defined for this function:
1344 The @var{filedes} argument is not a valid file descriptor.
1347 The value of @var{parameter} is invalid, or the implementation doesn't
1348 support the @var{parameter} for the specific file.
1352 Here are the symbolic constants that you can use as the @var{parameter}
1353 argument to @code{pathconf} and @code{fpathconf}. The values are all
1360 Inquire about the value of @code{LINK_MAX}.
1365 Inquire about the value of @code{MAX_CANON}.
1370 Inquire about the value of @code{MAX_INPUT}.
1375 Inquire about the value of @code{NAME_MAX}.
1380 Inquire about the value of @code{PATH_MAX}.
1385 Inquire about the value of @code{PIPE_BUF}.
1389 @item _PC_CHOWN_RESTRICTED
1390 Inquire about the value of @code{_POSIX_CHOWN_RESTRICTED}.
1395 Inquire about the value of @code{_POSIX_NO_TRUNC}.
1400 Inquire about the value of @code{_POSIX_VDISABLE}.
1405 Inquire about the value of @code{_POSIX_SYNC_IO}.
1410 Inquire about the value of @code{_POSIX_ASYNC_IO}.
1415 Inquire about the value of @code{_POSIX_PRIO_IO}.
1419 @item _PC_SOCK_MAXBUF
1420 Inquire about the value of @code{_POSIX_PIPE_BUF}.
1423 @node Utility Limits
1424 @section Utility Program Capacity Limits
1426 The POSIX.2 standard specifies certain system limits that you can access
1427 through @code{sysconf} that apply to utility behavior rather than the
1428 behavior of the library or the operating system.
1430 The GNU C library defines macros for these limits, and @code{sysconf}
1431 returns values for them if you ask; but these values convey no
1432 meaningful information. They are simply the smallest values that
1437 @deftypevr Macro int BC_BASE_MAX
1438 The largest value of @code{obase} that the @code{bc} utility is
1439 guaranteed to support.
1444 @deftypevr Macro int BC_SCALE_MAX
1445 The largest value of @code{scale} that the @code{bc} utility is
1446 guaranteed to support.
1451 @deftypevr Macro int BC_DIM_MAX
1452 The largest number of elements in one array that the @code{bc} utility
1453 is guaranteed to support.
1458 @deftypevr Macro int BC_STRING_MAX
1459 The largest number of characters in one string constant that the
1460 @code{bc} utility is guaranteed to support.
1465 @deftypevr Macro int BC_DIM_MAX
1466 The largest number of elements in one array that the @code{bc} utility
1467 is guaranteed to support.
1472 @deftypevr Macro int COLL_WEIGHTS_MAX
1473 The largest number of weights that can necessarily be used in defining
1474 the collating sequence for a locale.
1479 @deftypevr Macro int EXPR_NEST_MAX
1480 The maximum number of expressions that can be nested within parenthesis
1481 by the @code{expr} utility.
1486 @deftypevr Macro int LINE_MAX
1487 The largest text line that the text-oriented POSIX.2 utilities can
1488 support. (If you are using the GNU versions of these utilities, then
1489 there is no actual limit except that imposed by the available virtual
1490 memory, but there is no way that the library can tell you this.)
1495 @deftypevr Macro int EQUIV_CLASS_MAX
1496 The maximum number of weights that can be assigned to an entry of the
1497 @code{LC_COLLATE} category @samp{order} keyword in a locale definition.
1498 The GNU C library does not presently support locale definitions.
1501 @node Utility Minimums
1502 @section Minimum Values for Utility Limits
1507 @item _POSIX2_BC_BASE_MAX
1508 The most restrictive limit permitted by POSIX.2 for the maximum value of
1509 @code{obase} in the @code{bc} utility. Its value is @code{99}.
1513 @item _POSIX2_BC_DIM_MAX
1514 The most restrictive limit permitted by POSIX.2 for the maximum size of
1515 an array in the @code{bc} utility. Its value is @code{2048}.
1519 @item _POSIX2_BC_SCALE_MAX
1520 The most restrictive limit permitted by POSIX.2 for the maximum value of
1521 @code{scale} in the @code{bc} utility. Its value is @code{99}.
1525 @item _POSIX2_BC_STRING_MAX
1526 The most restrictive limit permitted by POSIX.2 for the maximum size of
1527 a string constant in the @code{bc} utility. Its value is @code{1000}.
1531 @item _POSIX2_COLL_WEIGHTS_MAX
1532 The most restrictive limit permitted by POSIX.2 for the maximum number
1533 of weights that can necessarily be used in defining the collating
1534 sequence for a locale. Its value is @code{2}.
1538 @item _POSIX2_EXPR_NEST_MAX
1539 The most restrictive limit permitted by POSIX.2 for the maximum number
1540 of expressions nested within parenthesis when using the @code{expr} utility.
1541 Its value is @code{32}.
1545 @item _POSIX2_LINE_MAX
1546 The most restrictive limit permitted by POSIX.2 for the maximum size of
1547 a text line that the text utilities can handle. Its value is
1552 @item _POSIX2_EQUIV_CLASS_MAX
1553 The most restrictive limit permitted by POSIX.2 for the maximum number
1554 of weights that can be assigned to an entry of the @code{LC_COLLATE}
1555 category @samp{order} keyword in a locale definition. Its value is
1556 @code{2}. The GNU C library does not presently support locale
1560 @node String Parameters
1561 @section String-Valued Parameters
1563 POSIX.2 defines a way to get string-valued parameters from the operating
1564 system with the function @code{confstr}:
1568 @deftypefun size_t confstr (int @var{parameter}, char *@var{buf}, size_t @var{len})
1569 This function reads the value of a string-valued system parameter,
1570 storing the string into @var{len} bytes of memory space starting at
1571 @var{buf}. The @var{parameter} argument should be one of the
1572 @samp{_CS_} symbols listed below.
1574 The normal return value from @code{confstr} is the length of the string
1575 value that you asked for. If you supply a null pointer for @var{buf},
1576 then @code{confstr} does not try to store the string; it just returns
1577 its length. A value of @code{0} indicates an error.
1579 If the string you asked for is too long for the buffer (that is, longer
1580 than @code{@var{len} - 1}), then @code{confstr} stores just that much
1581 (leaving room for the terminating null character). You can tell that
1582 this has happened because @code{confstr} returns a value greater than or
1585 The following @code{errno} error conditions are defined for this function:
1589 The value of the @var{parameter} is invalid.
1593 Currently there is just one parameter you can read with @code{confstr}:
1599 This parameter's value is the recommended default path for searching for
1600 executable files. This is the path that a user has by default just
1605 @item _CS_LFS_CFLAGS
1606 The returned string specifies which additional flags must be given to
1607 the C compiler if a source is compiled using the
1608 @code{_LARGEFILE_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1612 @item _CS_LFS_LDFLAGS
1613 The returned string specifies which additional flags must be given to
1614 the linker if a source is compiled using the
1615 @code{_LARGEFILE_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1620 The returned string specifies which additional libraries must be linked
1621 to the application if a source is compiled using the
1622 @code{_LARGEFILE_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1626 @item _CS_LFS_LINTFLAGS
1627 The returned string specifies which additional flags must be given to
1628 the lint tool if a source is compiled using the
1629 @code{_LARGEFILE_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1633 @item _CS_LFS64_CFLAGS
1634 The returned string specifies which additional flags must be given to
1635 the C compiler if a source is compiled using the
1636 @code{_LARGEFILE64_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1640 @item _CS_LFS64_LDFLAGS
1641 The returned string specifies which additional flags must be given to
1642 the linker if a source is compiled using the
1643 @code{_LARGEFILE64_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1647 @item _CS_LFS64_LIBS
1648 The returned string specifies which additional libraries must be linked
1649 to the application if a source is compiled using the
1650 @code{_LARGEFILE64_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1654 @item _CS_LFS64_LINTFLAGS
1655 The returned string specifies which additional flags must be given to
1656 the lint tool if a source is compiled using the
1657 @code{_LARGEFILE64_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1660 The way to use @code{confstr} without any arbitrary limit on string size
1661 is to call it twice: first call it to get the length, allocate the
1662 buffer accordingly, and then call @code{confstr} again to fill the
1668 get_default_path (void)
1670 size_t len = confstr (_CS_PATH, NULL, 0);
1671 char *buffer = (char *) xmalloc (len);
1673 if (confstr (_CS_PATH, buf, len + 1) == 0)