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