1 @node System Configuration, Cryptographic Functions, System Management, Top
2 @c %MENU% Parameters describing operating system limits
3 @chapter System Configuration Parameters
5 The functions and macros listed in this chapter give information about
6 configuration parameters of the operating system---for example, capacity
7 limits, presence of optional POSIX features, and the default path for
8 executable files (@pxref{String Parameters}).
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.
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.
27 * Utility Limits:: Capacity limits of some POSIX.2 utility programs.
28 * Utility Minimums:: Minimum allowable values of those limits.
30 * String Parameters:: Getting the default search path.
34 @section General Capacity Limits
35 @cindex POSIX capacity limits
37 @cindex capacity limits, POSIX
39 The POSIX.1 and POSIX.2 standards specify a number of parameters that
40 describe capacity limitations of the system. These limits can be fixed
41 constants for a given operating system, or they can vary from machine to
42 machine. For example, some limit values may be configurable by the
43 system administrator, either at run time or by rebuilding the kernel,
44 and this should not require recompiling application programs.
47 Each 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
49 parameter in question. If the system allows different file systems or
50 files to have different limits, then the macro is undefined; use
51 @code{sysconf} to find out the limit that applies at a particular time
52 on a particular machine. @xref{Sysconf}.
54 Each of these parameters also has another macro, with a name starting
55 with @samp{_POSIX}, which gives the lowest value that the limit is
56 allowed to have on @emph{any} POSIX system. @xref{Minimums}.
58 @cindex limits, program argument size
61 @deftypevr Macro int ARG_MAX
62 If defined, the unvarying maximum combined length of the @var{argv} and
63 @var{environ} arguments that can be passed to the @code{exec} functions.
66 @cindex limits, number of processes
69 @deftypevr Macro int CHILD_MAX
70 If defined, the unvarying maximum number of processes that can exist
71 with the same real user ID at any one time. In BSD and GNU, this is
72 controlled by the @code{RLIMIT_NPROC} resource limit; @pxref{Limits on
76 @cindex limits, number of open files
79 @deftypevr Macro int OPEN_MAX
80 If defined, the unvarying maximum number of files that a single process
81 can have open simultaneously. In BSD and GNU, this is controlled
82 by the @code{RLIMIT_NOFILE} resource limit; @pxref{Limits on Resources}.
87 @deftypevr Macro int STREAM_MAX
88 If defined, the unvarying maximum number of streams that a single
89 process can have open simultaneously. @xref{Opening Streams}.
92 @cindex limits, time zone name length
95 @deftypevr Macro int TZNAME_MAX
96 If defined, the unvarying maximum length of a time zone name.
97 @xref{Time Zone Functions}.
100 These limit macros are always defined in @file{limits.h}.
102 @cindex limits, number of supplementary group IDs
105 @deftypevr Macro int NGROUPS_MAX
106 The maximum number of supplementary group IDs that one process can have.
108 The value of this macro is actually a lower bound for the maximum. That
109 is, you can count on being able to have that many supplementary group
110 IDs, 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
112 more (@pxref{Sysconf}).
117 @deftypevr Macro ssize_t SSIZE_MAX
118 The largest value that can fit in an object of type @code{ssize_t}.
119 Effectively, this is the limit on the number of bytes that can be read
120 or written in a single operation.
122 This macro is defined in all POSIX systems because this limit is never
128 @deftypevr Macro int RE_DUP_MAX
129 The largest number of repetitions you are guaranteed is allowed in the
130 construct @samp{\@{@var{min},@var{max}\@}} in a regular expression.
132 The value of this macro is actually a lower bound for the maximum. That
133 is, you can count on being able to have that many repetitions, but a
134 particular machine might let you have even more. You can use
135 @code{sysconf} to see whether a particular machine will let you have
136 more (@pxref{Sysconf}). And even the value that @code{sysconf} tells
137 you is just a lower bound---larger values might work.
139 This macro is defined in all POSIX.2 systems, because POSIX.2 says it
140 should always be defined even if there is no specific imposed limit.
144 @section Overall System Options
145 @cindex POSIX optional features
146 @cindex optional POSIX features
148 POSIX defines certain system-specific options that not all POSIX systems
149 support. Since these options are provided in the kernel, not in the
150 library, simply using @theglibc{} does not guarantee any of these
151 features is supported; it depends on the system you are using.
154 You can test for the availability of a given option using the macros in
155 this section, together with the function @code{sysconf}. The macros are
156 defined only if you include @file{unistd.h}.
158 For the following macros, if the macro is defined in @file{unistd.h},
159 then the option is supported. Otherwise, the option may or may not be
160 supported; use @code{sysconf} to find out. @xref{Sysconf}.
164 @deftypevr Macro int _POSIX_JOB_CONTROL
165 If this symbol is defined, it indicates that the system supports job
166 control. Otherwise, the implementation behaves as if all processes
167 within a session belong to a single process group. @xref{Job Control}.
172 @deftypevr Macro int _POSIX_SAVED_IDS
173 If this symbol is defined, it indicates that the system remembers the
174 effective user and group IDs of a process before it executes an
175 executable file with the set-user-ID or set-group-ID bits set, and that
176 explicitly changing the effective user or group IDs back to these values
177 is permitted. If this option is not defined, then if a nonprivileged
178 process changes its effective user or group ID to the real user or group
179 ID of the process, it can't change it back again. @xref{Enable/Disable
183 For the following macros, if the macro is defined in @file{unistd.h},
184 then 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
186 defined, then the option may or may not be supported; use @code{sysconf}
187 to find out. @xref{Sysconf}.
191 @deftypevr Macro int _POSIX2_C_DEV
192 If this symbol is defined, it indicates that the system has the POSIX.2
193 C compiler command, @code{c89}. @Theglibc{} always defines this
194 as @code{1}, on the assumption that you would not have installed it if
195 you didn't have a C compiler.
200 @deftypevr Macro int _POSIX2_FORT_DEV
201 If this symbol is defined, it indicates that the system has the POSIX.2
202 Fortran compiler command, @code{fort77}. @Theglibc{} never
203 defines this, because we don't know what the system has.
208 @deftypevr Macro int _POSIX2_FORT_RUN
209 If this symbol is defined, it indicates that the system has the POSIX.2
210 @code{asa} command to interpret Fortran carriage control. @Theglibc{}
211 never defines this, because we don't know what the system has.
216 @deftypevr Macro int _POSIX2_LOCALEDEF
217 If this symbol is defined, it indicates that the system has the POSIX.2
218 @code{localedef} command. @Theglibc{} never defines this, because
219 we don't know what the system has.
224 @deftypevr Macro int _POSIX2_SW_DEV
225 If this symbol is defined, it indicates that the system has the POSIX.2
226 commands @code{ar}, @code{make}, and @code{strip}. @Theglibc{}
227 always 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.
232 @node Version Supported
233 @section Which Version of POSIX is Supported
237 @deftypevr Macro {long int} _POSIX_VERSION
238 This constant represents the version of the POSIX.1 standard to which
239 the implementation conforms. For an implementation conforming to the
240 1995 POSIX.1 standard, the value is the integer @code{199506L}.
242 @code{_POSIX_VERSION} is always defined (in @file{unistd.h}) in any
245 @strong{Usage Note:} Don't try to test whether the system supports POSIX
246 by including @file{unistd.h} and then checking whether
247 @code{_POSIX_VERSION} is defined. On a non-POSIX system, this will
248 probably 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
250 target system supports POSIX or whether @file{unistd.h} exists.
255 @deftypevr Macro {long int} _POSIX2_C_VERSION
256 This constant represents the version of the POSIX.2 standard which the
257 library and system kernel support. We don't know what value this will
258 be for the first version of the POSIX.2 standard, because the value is
259 based on the year and month in which the standard is officially adopted.
261 The value of this symbol says nothing about the utilities installed on
264 @strong{Usage Note:} You can use this macro to tell whether a POSIX.1
265 system 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)}.
271 @section Using @code{sysconf}
273 When your system has configurable system limits, you can use the
274 @code{sysconf} function to find out the value that applies to any
275 particular machine. The function and the associated @var{parameter}
276 constants are declared in the header file @file{unistd.h}.
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.
285 @node Sysconf Definition
286 @subsection Definition of @code{sysconf}
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.
302 This function is used to inquire about runtime system parameters. The
303 @var{parameter} argument should be one of the @samp{_SC_} symbols listed
306 The normal return value from @code{sysconf} is the value you requested.
307 A value of @code{-1} is returned both if the implementation does not
308 impose a limit, and in case of an error.
310 The following @code{errno} error conditions are defined for this function:
314 The value of the @var{parameter} is invalid.
318 @node Constants for Sysconf
319 @subsection Constants for @code{sysconf} Parameters
321 Here are the symbolic constants for use as the @var{parameter} argument
322 to @code{sysconf}. The values are all integer constants (more
323 specifically, enumeration type values).
329 Inquire about the parameter corresponding to @code{ARG_MAX}.
334 Inquire about the parameter corresponding to @code{CHILD_MAX}.
339 Inquire about the parameter corresponding to @code{OPEN_MAX}.
344 Inquire about the parameter corresponding to @code{STREAM_MAX}.
349 Inquire about the parameter corresponding to @code{TZNAME_MAX}.
353 @item _SC_NGROUPS_MAX
354 Inquire about the parameter corresponding to @code{NGROUPS_MAX}.
358 @item _SC_JOB_CONTROL
359 Inquire about the parameter corresponding to @code{_POSIX_JOB_CONTROL}.
364 Inquire about the parameter corresponding to @code{_POSIX_SAVED_IDS}.
369 Inquire about the parameter corresponding to @code{_POSIX_VERSION}.
374 Inquire about the number of clock ticks per second; @pxref{CPU Time}.
375 The corresponding parameter @code{CLK_TCK} is obsolete.
379 @item _SC_CHARCLASS_NAME_MAX
380 Inquire about the parameter corresponding to maximal length allowed for
381 a character class name in an extended locale specification. These
382 extensions are not yet standardized and so this option is not standardized
387 @item _SC_REALTIME_SIGNALS
388 Inquire about the parameter corresponding to @code{_POSIX_REALTIME_SIGNALS}.
392 @item _SC_PRIORITY_SCHEDULING
393 Inquire about the parameter corresponding to @code{_POSIX_PRIORITY_SCHEDULING}.
398 Inquire about the parameter corresponding to @code{_POSIX_TIMERS}.
402 @item _SC_ASYNCHRONOUS_IO
403 Inquire about the parameter corresponding to @code{_POSIX_ASYNCHRONOUS_IO}.
407 @item _SC_PRIORITIZED_IO
408 Inquire about the parameter corresponding to @code{_POSIX_PRIORITIZED_IO}.
412 @item _SC_SYNCHRONIZED_IO
413 Inquire about the parameter corresponding to @code{_POSIX_SYNCHRONIZED_IO}.
418 Inquire about the parameter corresponding to @code{_POSIX_FSYNC}.
422 @item _SC_MAPPED_FILES
423 Inquire about the parameter corresponding to @code{_POSIX_MAPPED_FILES}.
428 Inquire about the parameter corresponding to @code{_POSIX_MEMLOCK}.
432 @item _SC_MEMLOCK_RANGE
433 Inquire about the parameter corresponding to @code{_POSIX_MEMLOCK_RANGE}.
437 @item _SC_MEMORY_PROTECTION
438 Inquire about the parameter corresponding to @code{_POSIX_MEMORY_PROTECTION}.
442 @item _SC_MESSAGE_PASSING
443 Inquire about the parameter corresponding to @code{_POSIX_MESSAGE_PASSING}.
448 Inquire about the parameter corresponding to @code{_POSIX_SEMAPHORES}.
452 @item _SC_SHARED_MEMORY_OBJECTS
453 Inquire about the parameter corresponding to@*
454 @code{_POSIX_SHARED_MEMORY_OBJECTS}.
458 @item _SC_AIO_LISTIO_MAX
459 Inquire about the parameter corresponding to @code{_POSIX_AIO_LISTIO_MAX}.
464 Inquire about the parameter corresponding to @code{_POSIX_AIO_MAX}.
468 @item _SC_AIO_PRIO_DELTA_MAX
469 Inquire the value by which a process can decrease its asynchronous I/O
470 priority level from its own scheduling priority. This corresponds to the
471 run-time invariant value @code{AIO_PRIO_DELTA_MAX}.
475 @item _SC_DELAYTIMER_MAX
476 Inquire about the parameter corresponding to @code{_POSIX_DELAYTIMER_MAX}.
480 @item _SC_MQ_OPEN_MAX
481 Inquire about the parameter corresponding to @code{_POSIX_MQ_OPEN_MAX}.
485 @item _SC_MQ_PRIO_MAX
486 Inquire about the parameter corresponding to @code{_POSIX_MQ_PRIO_MAX}.
491 Inquire about the parameter corresponding to @code{_POSIX_RTSIG_MAX}.
495 @item _SC_SEM_NSEMS_MAX
496 Inquire about the parameter corresponding to @code{_POSIX_SEM_NSEMS_MAX}.
500 @item _SC_SEM_VALUE_MAX
501 Inquire about the parameter corresponding to @code{_POSIX_SEM_VALUE_MAX}.
505 @item _SC_SIGQUEUE_MAX
506 Inquire about the parameter corresponding to @code{_POSIX_SIGQUEUE_MAX}.
511 Inquire about the parameter corresponding to @code{_POSIX_TIMER_MAX}.
516 Inquire about the parameter corresponding to @code{_POSIX_PII}.
521 Inquire about the parameter corresponding to @code{_POSIX_PII_XTI}.
526 Inquire about the parameter corresponding to @code{_POSIX_PII_SOCKET}.
530 @item _SC_PII_INTERNET
531 Inquire about the parameter corresponding to @code{_POSIX_PII_INTERNET}.
536 Inquire about the parameter corresponding to @code{_POSIX_PII_OSI}.
541 Inquire about the parameter corresponding to @code{_POSIX_SELECT}.
546 Inquire about the parameter corresponding to @code{_POSIX_UIO_MAXIOV}.
550 @item _SC_PII_INTERNET_STREAM
551 Inquire about the parameter corresponding to @code{_POSIX_PII_INTERNET_STREAM}.
555 @item _SC_PII_INTERNET_DGRAM
556 Inquire about the parameter corresponding to @code{_POSIX_PII_INTERNET_DGRAM}.
560 @item _SC_PII_OSI_COTS
561 Inquire about the parameter corresponding to @code{_POSIX_PII_OSI_COTS}.
565 @item _SC_PII_OSI_CLTS
566 Inquire about the parameter corresponding to @code{_POSIX_PII_OSI_CLTS}.
571 Inquire about the parameter corresponding to @code{_POSIX_PII_OSI_M}.
576 Inquire the value of the value associated with the @code{T_IOV_MAX}
582 Inquire about the parameter corresponding to @code{_POSIX_THREADS}.
586 @item _SC_THREAD_SAFE_FUNCTIONS
587 Inquire about the parameter corresponding to@*
588 @code{_POSIX_THREAD_SAFE_FUNCTIONS}.
592 @item _SC_GETGR_R_SIZE_MAX
593 Inquire about the parameter corresponding to @code{_POSIX_GETGR_R_SIZE_MAX}.
597 @item _SC_GETPW_R_SIZE_MAX
598 Inquire about the parameter corresponding to @code{_POSIX_GETPW_R_SIZE_MAX}.
602 @item _SC_LOGIN_NAME_MAX
603 Inquire about the parameter corresponding to @code{_POSIX_LOGIN_NAME_MAX}.
607 @item _SC_TTY_NAME_MAX
608 Inquire about the parameter corresponding to @code{_POSIX_TTY_NAME_MAX}.
612 @item _SC_THREAD_DESTRUCTOR_ITERATIONS
613 Inquire about the parameter corresponding to
614 @code{_POSIX_THREAD_DESTRUCTOR_ITERATIONS}.
618 @item _SC_THREAD_KEYS_MAX
619 Inquire about the parameter corresponding to @code{_POSIX_THREAD_KEYS_MAX}.
623 @item _SC_THREAD_STACK_MIN
624 Inquire about the parameter corresponding to @code{_POSIX_THREAD_STACK_MIN}.
628 @item _SC_THREAD_THREADS_MAX
629 Inquire about the parameter corresponding to @code{_POSIX_THREAD_THREADS_MAX}.
633 @item _SC_THREAD_ATTR_STACKADDR
634 Inquire about the parameter corresponding to@*a
635 @code{_POSIX_THREAD_ATTR_STACKADDR}.
639 @item _SC_THREAD_ATTR_STACKSIZE
640 Inquire about the parameter corresponding to@*
641 @code{_POSIX_THREAD_ATTR_STACKSIZE}.
645 @item _SC_THREAD_PRIORITY_SCHEDULING
646 Inquire about the parameter corresponding to
647 @code{_POSIX_THREAD_PRIORITY_SCHEDULING}.
651 @item _SC_THREAD_PRIO_INHERIT
652 Inquire about the parameter corresponding to @code{_POSIX_THREAD_PRIO_INHERIT}.
656 @item _SC_THREAD_PRIO_PROTECT
657 Inquire about the parameter corresponding to @code{_POSIX_THREAD_PRIO_PROTECT}.
661 @item _SC_THREAD_PROCESS_SHARED
662 Inquire about the parameter corresponding to
663 @code{_POSIX_THREAD_PROCESS_SHARED}.
668 Inquire about whether the system has the POSIX.2 C compiler command,
674 Inquire about whether the system has the POSIX.2 Fortran compiler
675 command, @code{fort77}.
680 Inquire about whether the system has the POSIX.2 @code{asa} command to
681 interpret Fortran carriage control.
685 @item _SC_2_LOCALEDEF
686 Inquire about whether the system has the POSIX.2 @code{localedef}
692 Inquire about whether the system has the POSIX.2 commands @code{ar},
693 @code{make}, and @code{strip}.
697 @item _SC_BC_BASE_MAX
698 Inquire about the maximum value of @code{obase} in the @code{bc}
704 Inquire about the maximum size of an array in the @code{bc}
709 @item _SC_BC_SCALE_MAX
710 Inquire about the maximum value of @code{scale} in the @code{bc}
715 @item _SC_BC_STRING_MAX
716 Inquire about the maximum size of a string constant in the
721 @item _SC_COLL_WEIGHTS_MAX
722 Inquire about the maximum number of weights that can necessarily
723 be used in defining the collating sequence for a locale.
727 @item _SC_EXPR_NEST_MAX
728 Inquire about the maximum number of expressions nested within
729 parentheses when using the @code{expr} utility.
734 Inquire about the maximum size of a text line that the POSIX.2 text
735 utilities can handle.
739 @item _SC_EQUIV_CLASS_MAX
740 Inquire about the maximum number of weights that can be assigned to an
741 entry of the @code{LC_COLLATE} category @samp{order} keyword in a locale
742 definition. @Theglibc{} does not presently support locale
748 Inquire about the version number of POSIX.1 that the library and kernel
754 Inquire about the version number of POSIX.2 that the system utilities
760 Inquire about the virtual memory page size of the machine.
761 @code{getpagesize} returns the same value (@pxref{Query Memory Parameters}).
765 @item _SC_NPROCESSORS_CONF
766 Inquire about the number of configured processors.
770 @item _SC_NPROCESSORS_ONLN
771 Inquire about the number of processors online.
776 Inquire about the number of physical pages in the system.
780 @item _SC_AVPHYS_PAGES
781 Inquire about the number of available physical pages in the system.
786 Inquire about the number of functions which can be registered as termination
787 functions for @code{atexit}; @pxref{Cleanups on Exit}.
791 @item _SC_XOPEN_VERSION
792 Inquire about the parameter corresponding to @code{_XOPEN_VERSION}.
796 @item _SC_XOPEN_XCU_VERSION
797 Inquire about the parameter corresponding to @code{_XOPEN_XCU_VERSION}.
802 Inquire about the parameter corresponding to @code{_XOPEN_UNIX}.
806 @item _SC_XOPEN_REALTIME
807 Inquire about the parameter corresponding to @code{_XOPEN_REALTIME}.
811 @item _SC_XOPEN_REALTIME_THREADS
812 Inquire about the parameter corresponding to @code{_XOPEN_REALTIME_THREADS}.
816 @item _SC_XOPEN_LEGACY
817 Inquire about the parameter corresponding to @code{_XOPEN_LEGACY}.
821 @item _SC_XOPEN_CRYPT
822 Inquire about the parameter corresponding to @code{_XOPEN_CRYPT}.
826 @item _SC_XOPEN_ENH_I18N
827 Inquire about the parameter corresponding to @code{_XOPEN_ENH_I18N}.
832 Inquire about the parameter corresponding to @code{_XOPEN_SHM}.
837 Inquire about the parameter corresponding to @code{_XOPEN_XPG2}.
842 Inquire about the parameter corresponding to @code{_XOPEN_XPG3}.
847 Inquire about the parameter corresponding to @code{_XOPEN_XPG4}.
852 Inquire about the number of bits in a variable of type @code{char}.
857 Inquire about the maximum value which can be stored in a variable of type
863 Inquire about the minimum value which can be stored in a variable of type
869 Inquire about the maximum value which can be stored in a variable of type
875 Inquire about the minimum value which can be stored in a variable of type
881 Inquire about the number of bits in a variable of type @code{long int}.
886 Inquire about the number of bits in a variable of a register word.
891 Inquire the maximum length of a multi-byte representation of a wide
897 Inquire about the value used to internally represent the zero priority level for
898 the process execution.
903 Inquire about the maximum value which can be stored in a variable of type
909 Inquire about the maximum value which can be stored in a variable of type
915 Inquire about the minimum value which can be stored in a variable of type
921 Inquire about the maximum value which can be stored in a variable of type
927 Inquire about the minimum value which can be stored in a variable of type
933 Inquire about the maximum value which can be stored in a variable of type
934 @code{unsigned char}.
939 Inquire about the maximum value which can be stored in a variable of type
945 Inquire about the maximum value which can be stored in a variable of type
946 @code{unsigned long int}.
951 Inquire about the maximum value which can be stored in a variable of type
952 @code{unsigned short int}.
957 Inquire about the parameter corresponding to @code{NL_ARGMAX}.
962 Inquire about the parameter corresponding to @code{NL_LANGMAX}.
967 Inquire about the parameter corresponding to @code{NL_MSGMAX}.
972 Inquire about the parameter corresponding to @code{NL_NMAX}.
977 Inquire about the parameter corresponding to @code{NL_SETMAX}.
982 Inquire about the parameter corresponding to @code{NL_TEXTMAX}.
985 @node Examples of Sysconf
986 @subsection Examples of @code{sysconf}
988 We recommend that you first test for a macro definition for the
989 parameter you are interested in, and call @code{sysconf} only if the
990 macro is not defined. For example, here is how to test whether job
991 control is supported:
996 have_job_control (void)
998 #ifdef _POSIX_JOB_CONTROL
1001 int value = sysconf (_SC_JOB_CONTROL);
1003 /* @r{If the system is that badly wedged,}
1004 @r{there's no use trying to go on.} */
1005 fatal (strerror (errno));
1012 Here is how to get the value of a numeric limit:
1021 int value = sysconf (_SC_CHILD_MAX);
1023 fatal (strerror (errno));
1030 @section Minimum Values for General Capacity Limits
1032 Here are the names for the POSIX minimum upper bounds for the system
1033 limit parameters. The significance of these values is that you can
1034 safely push to these limits without checking whether the particular
1035 system you are using can go that far.
1040 @item _POSIX_AIO_LISTIO_MAX
1041 The most restrictive limit permitted by POSIX for the maximum number of
1042 I/O operations that can be specified in a list I/O call. The value of
1043 this constant is @code{2}; thus you can add up to two new entries
1044 of the list of outstanding operations.
1048 @item _POSIX_AIO_MAX
1049 The most restrictive limit permitted by POSIX for the maximum number of
1050 outstanding asynchronous I/O operations. The value of this constant is
1051 @code{1}. So you cannot expect that you can issue more than one
1052 operation and immediately continue with the normal work, receiving the
1053 notifications asynchronously.
1057 @item _POSIX_ARG_MAX
1058 The value of this macro is the most restrictive limit permitted by POSIX
1059 for the maximum combined length of the @var{argv} and @var{environ}
1060 arguments that can be passed to the @code{exec} functions.
1061 Its value is @code{4096}.
1065 @item _POSIX_CHILD_MAX
1066 The value of this macro is the most restrictive limit permitted by POSIX
1067 for the maximum number of simultaneous processes per real user ID. Its
1072 @item _POSIX_NGROUPS_MAX
1073 The value of this macro is the most restrictive limit permitted by POSIX
1074 for the maximum number of supplementary group IDs per process. Its
1079 @item _POSIX_OPEN_MAX
1080 The value of this macro is the most restrictive limit permitted by POSIX
1081 for the maximum number of files that a single process can have open
1082 simultaneously. Its value is @code{16}.
1086 @item _POSIX_SSIZE_MAX
1087 The value of this macro is the most restrictive limit permitted by POSIX
1088 for the maximum value that can be stored in an object of type
1089 @code{ssize_t}. Its value is @code{32767}.
1093 @item _POSIX_STREAM_MAX
1094 The value of this macro is the most restrictive limit permitted by POSIX
1095 for the maximum number of streams that a single process can have open
1096 simultaneously. Its value is @code{8}.
1100 @item _POSIX_TZNAME_MAX
1101 The value of this macro is the most restrictive limit permitted by POSIX
1102 for the maximum length of a time zone name. Its value is @code{3}.
1106 @item _POSIX2_RE_DUP_MAX
1107 The value of this macro is the most restrictive limit permitted by POSIX
1108 for the numbers used in the @samp{\@{@var{min},@var{max}\@}} construct
1109 in a regular expression. Its value is @code{255}.
1112 @node Limits for Files
1113 @section Limits on File System Capacity
1115 The POSIX.1 standard specifies a number of parameters that describe the
1116 limitations of the file system. It's possible for the system to have a
1117 fixed, uniform limit for a parameter, but this isn't the usual case. On
1118 most systems, it's possible for different file systems (and, for some
1119 parameters, even different files) to have different maximum limits. For
1120 example, this is very likely if you use NFS to mount some of the file
1121 systems from other machines.
1124 Each of the following macros is defined in @file{limits.h} only if the
1125 system has a fixed, uniform limit for the parameter in question. If the
1126 system allows different file systems or files to have different limits,
1127 then the macro is undefined; use @code{pathconf} or @code{fpathconf} to
1128 find out the limit that applies to a particular file. @xref{Pathconf}.
1130 Each parameter also has another macro, with a name starting with
1131 @samp{_POSIX}, which gives the lowest value that the limit is allowed to
1132 have on @emph{any} POSIX system. @xref{File Minimums}.
1134 @cindex limits, link count of files
1135 @comment limits.h (optional)
1137 @deftypevr Macro int LINK_MAX
1138 The uniform system limit (if any) for the number of names for a given
1139 file. @xref{Hard Links}.
1142 @cindex limits, terminal input queue
1145 @deftypevr Macro int MAX_CANON
1146 The uniform system limit (if any) for the amount of text in a line of
1147 input when input editing is enabled. @xref{Canonical or Not}.
1152 @deftypevr Macro int MAX_INPUT
1153 The uniform system limit (if any) for the total number of characters
1154 typed ahead as input. @xref{I/O Queues}.
1157 @cindex limits, file name length
1160 @deftypevr Macro int NAME_MAX
1161 The uniform system limit (if any) for the length of a file name component, not
1162 including the terminating null character.
1164 @strong{Portability Note:} On some systems, @theglibc{} defines
1165 @code{NAME_MAX}, but does not actually enforce this limit.
1170 @deftypevr Macro int PATH_MAX
1171 The uniform system limit (if any) for the length of an entire file name (that
1172 is, the argument given to system calls such as @code{open}), including the
1173 terminating null character.
1175 @strong{Portability Note:} @Theglibc{} does not enforce this limit
1176 even if @code{PATH_MAX} is defined.
1179 @cindex limits, pipe buffer size
1182 @deftypevr Macro int PIPE_BUF
1183 The uniform system limit (if any) for the number of bytes that can be
1184 written atomically to a pipe. If multiple processes are writing to the
1185 same pipe simultaneously, output from different processes might be
1186 interleaved in chunks of this size. @xref{Pipes and FIFOs}.
1189 These are alternative macro names for some of the same information.
1193 @deftypevr Macro int MAXNAMLEN
1194 This is the BSD name for @code{NAME_MAX}. It is defined in
1200 @deftypevr Macro int FILENAME_MAX
1201 The value of this macro is an integer constant expression that
1202 represents the maximum length of a file name string. It is defined in
1205 Unlike @code{PATH_MAX}, this macro is defined even if there is no actual
1206 limit imposed. In such a case, its value is typically a very large
1207 number. @strong{This is always the case on @gnuhurdsystems{}.}
1209 @strong{Usage Note:} Don't use @code{FILENAME_MAX} as the size of an
1210 array in which to store a file name! You can't possibly make an array
1211 that big! Use dynamic allocation (@pxref{Memory Allocation}) instead.
1214 @node Options for Files
1215 @section Optional Features in File Support
1217 POSIX defines certain system-specific options in the system calls for
1218 operating on files. Some systems support these options and others do
1219 not. Since these options are provided in the kernel, not in the
1220 library, simply using @theglibc{} does not guarantee that any of these
1221 features is supported; it depends on the system you are using. They can
1222 also vary between file systems on a single machine.
1225 This section describes the macros you can test to determine whether a
1226 particular option is supported on your machine. If a given macro is
1227 defined in @file{unistd.h}, then its value says whether the
1228 corresponding feature is supported. (A value of @code{-1} indicates no;
1229 any other value indicates yes.) If the macro is undefined, it means
1230 particular files may or may not support the feature.
1232 Since all the machines that support @theglibc{} also support NFS,
1233 one can never make a general statement about whether all file systems
1234 support the @code{_POSIX_CHOWN_RESTRICTED} and @code{_POSIX_NO_TRUNC}
1235 features. So these names are never defined as macros in @theglibc{}.
1239 @deftypevr Macro int _POSIX_CHOWN_RESTRICTED
1240 If this option is in effect, the @code{chown} function is restricted so
1241 that the only changes permitted to nonprivileged processes is to change
1242 the group owner of a file to either be the effective group ID of the
1243 process, or one of its supplementary group IDs. @xref{File Owner}.
1248 @deftypevr Macro int _POSIX_NO_TRUNC
1249 If this option is in effect, file name components longer than
1250 @code{NAME_MAX} generate an @code{ENAMETOOLONG} error. Otherwise, file
1251 name components that are too long are silently truncated.
1256 @deftypevr Macro {unsigned char} _POSIX_VDISABLE
1257 This option is only meaningful for files that are terminal devices.
1258 If it is enabled, then handling for special control characters can
1259 be disabled individually. @xref{Special Characters}.
1263 If one of these macros is undefined, that means that the option might be
1264 in effect for some files and not for others. To inquire about a
1265 particular file, call @code{pathconf} or @code{fpathconf}.
1269 @section Minimum Values for File System Limits
1271 Here are the names for the POSIX minimum upper bounds for some of the
1272 above parameters. The significance of these values is that you can
1273 safely push to these limits without checking whether the particular
1274 system you are using can go that far. In most cases @gnusystems{} do not
1275 have these strict limitations. The actual limit should be requested if
1281 @item _POSIX_LINK_MAX
1282 The most restrictive limit permitted by POSIX for the maximum value of a
1283 file's link count. The value of this constant is @code{8}; thus, you
1284 can always make up to eight names for a file without running into a
1289 @item _POSIX_MAX_CANON
1290 The most restrictive limit permitted by POSIX for the maximum number of
1291 bytes in a canonical input line from a terminal device. The value of
1292 this constant is @code{255}.
1296 @item _POSIX_MAX_INPUT
1297 The most restrictive limit permitted by POSIX for the maximum number of
1298 bytes in a terminal device input queue (or typeahead buffer).
1299 @xref{Input Modes}. The value of this constant is @code{255}.
1303 @item _POSIX_NAME_MAX
1304 The most restrictive limit permitted by POSIX for the maximum number of
1305 bytes in a file name component. The value of this constant is
1310 @item _POSIX_PATH_MAX
1311 The most restrictive limit permitted by POSIX for the maximum number of
1312 bytes in a file name. The value of this constant is @code{256}.
1316 @item _POSIX_PIPE_BUF
1317 The most restrictive limit permitted by POSIX for the maximum number of
1318 bytes that can be written atomically to a pipe. The value of this
1319 constant is @code{512}.
1324 Maximum number of bytes in a symbolic link.
1328 @item POSIX_REC_INCR_XFER_SIZE
1329 Recommended increment for file transfer sizes between the
1330 @code{POSIX_REC_MIN_XFER_SIZE} and @code{POSIX_REC_MAX_XFER_SIZE}
1335 @item POSIX_REC_MAX_XFER_SIZE
1336 Maximum recommended file transfer size.
1340 @item POSIX_REC_MIN_XFER_SIZE
1341 Minimum recommended file transfer size.
1345 @item POSIX_REC_XFER_ALIGN
1346 Recommended file transfer buffer alignment.
1350 @section Using @code{pathconf}
1352 When your machine allows different files to have different values for a
1353 file system parameter, you can use the functions in this section to find
1354 out the value that applies to any particular file.
1356 These functions and the associated constants for the @var{parameter}
1357 argument are declared in the header file @file{unistd.h}.
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.
1367 This function is used to inquire about the limits that apply to
1368 the file named @var{filename}.
1370 The @var{parameter} argument should be one of the @samp{_PC_} constants
1373 The normal return value from @code{pathconf} is the value you requested.
1374 A value of @code{-1} is returned both if the implementation does not
1375 impose 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
1377 to indicate the cause of the problem. So the only way to use this
1378 function robustly is to store @code{0} into @code{errno} just before
1381 Besides the usual file name errors (@pxref{File Name Errors}),
1382 the following error condition is defined for this function:
1386 The value of @var{parameter} is invalid, or the implementation doesn't
1387 support the @var{parameter} for the specific file.
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.
1396 This is just like @code{pathconf} except that an open file descriptor
1397 is used to specify the file for which information is requested, instead
1400 The following @code{errno} error conditions are defined for this function:
1404 The @var{filedes} argument is not a valid file descriptor.
1407 The value of @var{parameter} is invalid, or the implementation doesn't
1408 support the @var{parameter} for the specific file.
1412 Here are the symbolic constants that you can use as the @var{parameter}
1413 argument to @code{pathconf} and @code{fpathconf}. The values are all
1420 Inquire about the value of @code{LINK_MAX}.
1425 Inquire about the value of @code{MAX_CANON}.
1430 Inquire about the value of @code{MAX_INPUT}.
1435 Inquire about the value of @code{NAME_MAX}.
1440 Inquire about the value of @code{PATH_MAX}.
1445 Inquire about the value of @code{PIPE_BUF}.
1449 @item _PC_CHOWN_RESTRICTED
1450 Inquire about the value of @code{_POSIX_CHOWN_RESTRICTED}.
1455 Inquire about the value of @code{_POSIX_NO_TRUNC}.
1460 Inquire about the value of @code{_POSIX_VDISABLE}.
1465 Inquire about the value of @code{_POSIX_SYNC_IO}.
1470 Inquire about the value of @code{_POSIX_ASYNC_IO}.
1475 Inquire about the value of @code{_POSIX_PRIO_IO}.
1479 @item _PC_FILESIZEBITS
1480 Inquire about the availability of large files on the filesystem.
1484 @item _PC_REC_INCR_XFER_SIZE
1485 Inquire about the value of @code{POSIX_REC_INCR_XFER_SIZE}.
1489 @item _PC_REC_MAX_XFER_SIZE
1490 Inquire about the value of @code{POSIX_REC_MAX_XFER_SIZE}.
1494 @item _PC_REC_MIN_XFER_SIZE
1495 Inquire about the value of @code{POSIX_REC_MIN_XFER_SIZE}.
1499 @item _PC_REC_XFER_ALIGN
1500 Inquire about the value of @code{POSIX_REC_XFER_ALIGN}.
1503 @strong{Portability Note:} On some systems, @theglibc{} does not
1504 enforce @code{_PC_NAME_MAX} or @code{_PC_PATH_MAX} limits.
1506 @node Utility Limits
1507 @section Utility Program Capacity Limits
1509 The POSIX.2 standard specifies certain system limits that you can access
1510 through @code{sysconf} that apply to utility behavior rather than the
1511 behavior of the library or the operating system.
1513 @Theglibc{} defines macros for these limits, and @code{sysconf}
1514 returns values for them if you ask; but these values convey no
1515 meaningful information. They are simply the smallest values that
1520 @deftypevr Macro int BC_BASE_MAX
1521 The largest value of @code{obase} that the @code{bc} utility is
1522 guaranteed to support.
1527 @deftypevr Macro int BC_DIM_MAX
1528 The largest number of elements in one array that the @code{bc} utility
1529 is guaranteed to support.
1534 @deftypevr Macro int BC_SCALE_MAX
1535 The largest value of @code{scale} that the @code{bc} utility is
1536 guaranteed to support.
1541 @deftypevr Macro int BC_STRING_MAX
1542 The largest number of characters in one string constant that the
1543 @code{bc} utility is guaranteed to support.
1548 @deftypevr Macro int COLL_WEIGHTS_MAX
1549 The largest number of weights that can necessarily be used in defining
1550 the collating sequence for a locale.
1555 @deftypevr Macro int EXPR_NEST_MAX
1556 The maximum number of expressions that can be nested within parenthesis
1557 by the @code{expr} utility.
1562 @deftypevr Macro int LINE_MAX
1563 The largest text line that the text-oriented POSIX.2 utilities can
1564 support. (If you are using the GNU versions of these utilities, then
1565 there is no actual limit except that imposed by the available virtual
1566 memory, but there is no way that the library can tell you this.)
1571 @deftypevr Macro int EQUIV_CLASS_MAX
1572 The 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.
1577 @node Utility Minimums
1578 @section Minimum Values for Utility Limits
1583 @item _POSIX2_BC_BASE_MAX
1584 The 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}.
1589 @item _POSIX2_BC_DIM_MAX
1590 The most restrictive limit permitted by POSIX.2 for the maximum size of
1591 an array in the @code{bc} utility. Its value is @code{2048}.
1595 @item _POSIX2_BC_SCALE_MAX
1596 The 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}.
1601 @item _POSIX2_BC_STRING_MAX
1602 The most restrictive limit permitted by POSIX.2 for the maximum size of
1603 a string constant in the @code{bc} utility. Its value is @code{1000}.
1607 @item _POSIX2_COLL_WEIGHTS_MAX
1608 The most restrictive limit permitted by POSIX.2 for the maximum number
1609 of weights that can necessarily be used in defining the collating
1610 sequence for a locale. Its value is @code{2}.
1614 @item _POSIX2_EXPR_NEST_MAX
1615 The most restrictive limit permitted by POSIX.2 for the maximum number
1616 of expressions nested within parenthesis when using the @code{expr} utility.
1617 Its value is @code{32}.
1621 @item _POSIX2_LINE_MAX
1622 The most restrictive limit permitted by POSIX.2 for the maximum size of
1623 a text line that the text utilities can handle. Its value is
1628 @item _POSIX2_EQUIV_CLASS_MAX
1629 The most restrictive limit permitted by POSIX.2 for the maximum number
1630 of weights that can be assigned to an entry of the @code{LC_COLLATE}
1631 category @samp{order} keyword in a locale definition. Its value is
1632 @code{2}. @Theglibc{} does not presently support locale
1636 @node String Parameters
1637 @section String-Valued Parameters
1639 POSIX.2 defines a way to get string-valued parameters from the operating
1640 system with the function @code{confstr}:
1644 @deftypefun size_t confstr (int @var{parameter}, char *@var{buf}, size_t @var{len})
1645 @safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
1646 This function reads the value of a string-valued system parameter,
1647 storing 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.
1651 The normal return value from @code{confstr} is the length of the string
1652 value that you asked for. If you supply a null pointer for @var{buf},
1653 then @code{confstr} does not try to store the string; it just returns
1654 its length. A value of @code{0} indicates an error.
1656 If the string you asked for is too long for the buffer (that is, longer
1657 than @code{@var{len} - 1}), then @code{confstr} stores just that much
1658 (leaving room for the terminating null character). You can tell that
1659 this has happened because @code{confstr} returns a value greater than or
1662 The following @code{errno} error conditions are defined for this function:
1666 The value of the @var{parameter} is invalid.
1670 Currently there is just one parameter you can read with @code{confstr}:
1676 This parameter's value is the recommended default path for searching for
1677 executable files. This is the path that a user has by default just
1682 @item _CS_LFS_CFLAGS
1683 The returned string specifies which additional flags must be given to
1684 the C compiler if a source is compiled using the
1685 @code{_LARGEFILE_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1689 @item _CS_LFS_LDFLAGS
1690 The returned string specifies which additional flags must be given to
1691 the linker if a source is compiled using the
1692 @code{_LARGEFILE_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1697 The returned string specifies which additional libraries must be linked
1698 to the application if a source is compiled using the
1699 @code{_LARGEFILE_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1703 @item _CS_LFS_LINTFLAGS
1704 The returned string specifies which additional flags must be given to
1705 the lint tool if a source is compiled using the
1706 @code{_LARGEFILE_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1710 @item _CS_LFS64_CFLAGS
1711 The returned string specifies which additional flags must be given to
1712 the C compiler if a source is compiled using the
1713 @code{_LARGEFILE64_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1717 @item _CS_LFS64_LDFLAGS
1718 The returned string specifies which additional flags must be given to
1719 the linker if a source is compiled using the
1720 @code{_LARGEFILE64_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1724 @item _CS_LFS64_LIBS
1725 The returned string specifies which additional libraries must be linked
1726 to the application if a source is compiled using the
1727 @code{_LARGEFILE64_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1731 @item _CS_LFS64_LINTFLAGS
1732 The returned string specifies which additional flags must be given to
1733 the lint tool if a source is compiled using the
1734 @code{_LARGEFILE64_SOURCE} feature select macro; @pxref{Feature Test Macros}.
1737 The way to use @code{confstr} without any arbitrary limit on string size
1738 is to call it twice: first call it to get the length, allocate the
1739 buffer accordingly, and then call @code{confstr} again to fill the
1745 get_default_path (void)
1747 size_t len = confstr (_CS_PATH, NULL, 0);
1748 char *buffer = (char *) xmalloc (len);
1750 if (confstr (_CS_PATH, buf, len + 1) == 0)