1.\" Copyright (c) 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 3. Neither the name of the University nor the names of its contributors 13.\" may be used to endorse or promote products derived from this software 14.\" without specific prior written permission. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26.\" SUCH DAMAGE. 27.\" 28.\" @(#)sysconf.3 8.3 (Berkeley) 4/19/94 29.\" $FreeBSD: src/lib/libc/gen/sysconf.3,v 1.8.2.6 2001/12/14 18:33:51 ru Exp $ 30.\" 31.Dd August 20, 2021 32.Dt SYSCONF 3 33.Os 34.Sh NAME 35.Nm sysconf 36.Nd get configurable system variables 37.Sh LIBRARY 38.Lb libc 39.Sh SYNOPSIS 40.In unistd.h 41.Ft long 42.Fn sysconf "int name" 43.Sh DESCRIPTION 44This interface is defined by 45.St -p1003.1-88 . 46A far more complete interface is available using 47.Xr sysctl 3 . 48.Pp 49The 50.Fn sysconf 51function provides a method for applications to determine the current 52value of a configurable system limit or option variable. 53The 54.Fa name 55argument specifies the system variable to be queried. 56Symbolic constants for each name value are found in the include file 57.In unistd.h . 58.Pp 59The available values are as follows: 60.Bl -tag -width 6n 61.It Dv _SC_ADVISORY_INFO 62The version of 63.St -p1003.1 64and its 65Advisory Information 66option to which the system attempts to conform, 67otherwise \-1. 68.It Dv _SC_AIO_LISTIO_MAX 69Maximum number of I/O operations in a single list I/O call supported. 70.It Dv _SC_AIO_MAX 71Maximum number of outstanding asynchronous I/O operations supported. 72.It Dv _SC_AIO_PRIO_DELTA_MAX 73The maximum amount by which a process can decrease its asynchronous I/O 74priority level from its own scheduling priority. 75.It Dv _SC_ASYNCHRONOUS_IO 76The version of 77.St -p1003.1 78and its 79Asynchronous Input and Output 80option to which the system attempts to conform, 81otherwise \-1. 82.It Dv _SC_ARG_MAX 83The maximum bytes of argument to 84.Xr execve 2 . 85.It Dv _SC_ATEXIT_MAX 86Maximum number of functions that may be registered with 87.Fn atexit . 88.It Dv _SC_BARRIERS 89The version of 90.St -p1003.1 91and its 92Barriers 93option to which the system attempts to conform, 94otherwise \-1. 95.It Dv _SC_BC_BASE_MAX 96The maximum ibase/obase values in the 97.Xr bc 1 98utility. 99.It Dv _SC_BC_DIM_MAX 100The maximum array size in the 101.Xr bc 1 102utility. 103.It Dv _SC_BC_SCALE_MAX 104The maximum scale value in the 105.Xr bc 1 106utility. 107.It Dv _SC_BC_STRING_MAX 108The maximum string length in the 109.Xr bc 1 110utility. 111.It Dv _SC_CHILD_MAX 112The maximum number of simultaneous processes per user id. 113.It Dv _SC_CLK_TCK 114The frequency of the statistics clock in ticks per second. 115.It Dv _SC_CLOCK_SELECTION 116Return the POSIX version the implementation of the Clock Selection Option 117on this system conforms to, or \-1 if unavailable. 118.It Dv _SC_COLL_WEIGHTS_MAX 119The maximum number of weights that can be assigned to any entry of 120the LC_COLLATE order keyword in the locale definition file. 121.It Dv _SC_CPUTIME 122The 123.Dv CLOCK_PROCESS_CPUTIME_ID 124clock ID is supported, otherwise \-1. 125.It Dv _SC_DELAYTIMER_MAX 126Maximum number of timer expiration overruns. 127.It Dv _SC_EXPR_NEST_MAX 128The maximum number of expressions that can be nested within 129parenthesis by the 130.Xr expr 1 131utility. 132.It Dv _SC_FSYNC 133Return 1 if the File Synchronization Option is available on this system, 134otherwise \-1. 135.It Dv _SC_GETGR_R_SIZE_MAX 136Suggested initial value for the size of the group entry buffer. 137.It Dv _SC_GETPW_R_SIZE_MAX 138Suggested initial value for the size of the password entry buffer. 139.It Dv _SC_HOST_NAME_MAX 140Maximum length of a host name (not including the terminating null) as 141returned from the 142.Xr gethostname 3 , 143function. 144.It Dv _SC_IOV_MAX 145The maximum number of elements in the I/O vector used by 146.Xr readv 2 , 147.Xr writev 2 , 148.Xr recvmsg 2 , 149and 150.Xr sendmsg 2 . 151.It Dv _SC_IPV6 152The version of 153.St -p1003.1 154and its 155IPv6 156option to which the system attempts to conform, 157otherwise \-1. 158.It Dv _SC_JOB_CONTROL 159Return 1 if job control is available on this system, otherwise \-1. 160.It Dv _SC_LINE_MAX 161The maximum length in bytes of a text-processing utility's input 162line. 163.It Dv _SC_LOGIN_NAME_MAX 164Maximum length of a login name. 165.It Dv _SC_MAPPED_FILES 166Return 1 if the Memory Mapped Files Option is available on this system, 167otherwise \-1. 168.It Dv _SC_MEMLOCK 169Return 1 if the Process Memory Locking Option is available on this system, 170otherwise \-1. 171.It Dv _SC_MEMLOCK_RANGE 172Return 1 if the Range Memory Locking Option is available on this system, 173otherwise \-1. 174.It Dv _SC_MEMORY_PROTECTION 175Return 1 if the Memory Protection Option is available on this system, 176otherwise \-1. 177.It Dv _SC_MESSAGE_PASSING 178Whether Message Passing option is supported. 179.It Dv _SC_MONOTONIC_CLOCK 180Return the POSIX version of the implementation of the Monotonic Clock 181option that this system conforms to, or \-1 if unavailable. 182.It Dv _SC_MQ_OPEN_MAX 183The maximum number of open message queue descriptors per process. 184.It Dv _SC_MQ_PRIO_MAX 185The maximum number of message priorities supported by the implementation. 186.It Dv _SC_NGROUPS_MAX 187The maximum number of supplemental groups. 188.It Dv _SC_OPEN_MAX 189The maximum number of open files per user id. 190.It Dv _SC_PAGESIZE 191The size of a system page in bytes. 192.It Dv _SC_PAGE_SIZE 193Equivalent to 194.Dv _SC_PAGESIZE . 195.It Dv _SC_PRIORITIZED_IO 196The version of 197.St -p1003.1 198and its 199Prioritized Input and Output 200option to which the system attempts to conform, 201otherwise \-1. 202.It Dv _SC_PRIORITY_SCHEDULING 203The version of 204.St -p1003.1 205and its 206Process Scheduling 207option to which the system attempts to conform, 208otherwise \-1. 209.It Dv _SC_RAW_SOCKETS 210The version of 211.St -p1003.1 212and its 213Raw Sockets 214option to which the system attempts to conform, 215otherwise \-1. 216.It Dv _SC_READER_WRITER_LOCKS 217The version of 218.St -p1003.1 219and its 220Read-Write Locks 221option to which the system attempts to conform, 222otherwise \-1. 223.It Dv _SC_REALTIME_SIGNALS 224The version of 225.St -p1003.1 226and its 227Realtime Signals Extension 228option to which the system attempts to conform, 229otherwise \-1. 230.It Dv _SC_RE_DUP_MAX 231The maximum number of repeated occurrences of a regular expression 232permitted when using interval notation. 233.It Dv _SC_REGEXP 234Return 1 if the system supports regular expression handling. 235.It Dv _SC_RTSIG_MAX 236Maximum number of realtime signals reserved for application use. 237.It Dv _SC_SAVED_IDS 238Return 1 if saved set-group and saved set-user ID is available, 239otherwise \-1. 240.It Dv _SC_SEMAPHORES 241The version of 242.St -p1003.1 243and its 244Semaphores 245option to which the system attempts to conform, 246otherwise \-1. 247.It Dv _SC_SEM_NSEMS_MAX 248Maximum number of semaphores that a process may have. 249.It Dv _SC_SEM_VALUE_MAX 250The maximum value a semaphore may have. 251.It Dv _SC_SHARED_MEMORY_OBJECTS 252The version of 253.St -p1003.1 254and its 255Shared Memory Objects 256option to which the system attempts to conform, 257otherwise \-1. 258.It Dv _SC_SHELL 259Return 1 if the system supports the 260.Tn POSIX 261shell. 262.It Dv _SC_SIGQUEUE_MAX 263Maximum number of queued signals that a process may send and have pending at 264the receiver(s) at any time. 265.It Dv _SC_SPAWN 266The version of 267.St -p1003.1 268and its 269Spawn 270option to which the system attempts to conform, 271otherwise \-1. 272.It Dv _SC_SPIN_LOCKS 273The version of 274.St -p1003.1 275and its 276Spin Locks 277option to which the system attempts to conform, 278otherwise \-1. 279.It Dv _SC_SPORADIC_SERVER 280The version of 281.St -p1003.1 282and its 283Process Sporadic Server 284option to which the system attempts to conform, 285otherwise \-1. 286.It Dv _SC_STREAM_MAX 287The maximum number of streams that a process may have open at any one time. 288.It Dv _SC_SYMLOOP_MAX 289Maximum number of symbolic links that can be reliably traversed in the 290resolution of a pathname in the absence of a loop. 291.It Dv _SC_SYNCHRONIZED_IO 292Return 1 if the Synchronized I/O Option is available on this system, 293otherwise \-1. 294.It Dv _SC_THREAD_ATTR_STACKADDR 295The version of 296.St -p1003.1 297and its 298Thread Stack Address Attribute 299option to which the system attempts to conform, 300otherwise \-1. 301.It Dv _SC_THREAD_ATTR_STACKSIZE 302The version of 303.St -p1003.1 304and its 305Thread Stack Size Attribute 306option to which the system attempts to conform, 307otherwise \-1. 308.It Dv _SC_THREAD_CPUTIME 309The 310.Dv CLOCK_THREAD_CPUTIME_ID 311clock ID is supported, otherwise \-1. 312.It Dv _SC_THREAD_PRIO_INHERIT 313The version of 314.St -p1003.1 315and its 316Thread Priority Inheritance 317option to which the system attempts to conform, 318otherwise \-1. 319.It Dv _SC_THREAD_PRIO_PROTECT 320Whether the system supports the priority ceiling protocol for POSIX threads. 321.It Dv _SC_THREAD_PRIORITY_SCHEDULING 322The version of 323.St -p1003.1 324and its 325Thread Execution Scheduling 326option to which the system attempts to conform, 327otherwise \-1. 328.It Dv _SC_THREAD_PROCESS_SHARED 329The version of 330.St -p1003.1 331and its 332Thread Process-Shared Synchronization 333option to which the system attempts to conform, 334otherwise \-1. 335.It Dv _SC_THREAD_ROBUST_PRIO_INHERIT 336The version of 337.St -p1003.1 338and its 339Robust Mutex Priority Inheritance 340option to which the system attempts to conform, 341otherwise \-1. 342.It Dv _SC_THREAD_ROBUST_PRIO_PROTECT 343The version of 344.St -p1003.1 345and its 346Robust Mutex Priority Protection 347option to which the system attempts to conform, 348otherwise \-1. 349.It Dv _SC_THREADS 350The version of 351.St -p1003.1 352and its 353Threads 354option to which the system attempts to conform, 355otherwise \-1. 356.It Dv _SC_THREAD_SAFE_FUNCTIONS 357The level of support for thread-safe (re-entrant) functions. 358.It Dv _SC_THREAD_SPORADIC_SERVER 359The version of 360.St -p1003.1 361and its 362Thread Sporadic Server 363option to which the system attempts to conform, 364otherwise \-1. 365.It Dv _SC_THREAD_STACK_MIN 366Minimum size in bytes of thread stack storage. 367.It Dv _SC_THREAD_THREADS_MAX 368Maximum number of threads that can be created per process. 369.It Dv _SC_TIMEOUTS 370The version of 371.St -p1003.1 372and its 373Timeouts 374option to which the system attempts to conform, 375otherwise \-1. 376.It Dv _SC_TIMER_MAX 377Maximum number of timers per process supported. 378.It Dv _SC_TIMERS 379The version of 380.St -p1003.1 381and its 382Timers 383option to which the system attempts to conform, 384otherwise \-1. 385.It Dv _SC_TTY_NAME_MAX 386Maximum length of terminal device name. 387.It Dv _SC_TYPED_MEMORY_OBJECTS 388The version of 389.St -p1003.1 390and its 391Typed Memory Objects 392option to which the system attempts to conform, 393otherwise \-1. 394.It Dv _SC_TZNAME_MAX 395The maximum number of bytes supported for the name of a timezone. 396.It Dv _SC_VERSION 397The version of 398.St -p1003.1 399with which the system 400attempts to comply. 401.It Dv _SC_XOPEN_SHM 402Return 1 if the system supports the 403.St -xpg4.2 404Shared Memory Feature 405for both compilation and execution, or 0 if only compilation support is 406guaranteed. 407.It Dv _SC_XOPEN_VERSION 408An integer value greater than or equal to 4, 409indicating the version of the X/Open Portability Guide to which this 410system conforms. 411.It Dv _SC_2_C_BIND 412Return 1 if the system's C-language development facilities support the 413C-Language Bindings Option, otherwise \-1. 414.It Dv _SC_2_C_DEV 415Return 1 if the system supports the C-Language Development Utilities Option, 416otherwise \-1. 417.It Dv _SC_2_CHAR_TERM 418Return 1 if the system supports at least one terminal type capable of 419all operations described in 420.St -p1003.2 , 421otherwise \-1. 422.It Dv _SC_2_FORT_DEV 423Return 1 if the system supports the FORTRAN Development Utilities Option, 424otherwise \-1. 425.It Dv _SC_2_FORT_RUN 426Return 1 if the system supports the FORTRAN Runtime Utilities Option, 427otherwise \-1. 428.It Dv _SC_2_LOCALEDEF 429Return 1 if the system supports the creation of locales, otherwise \-1. 430.It Dv _SC_2_SW_DEV 431Return 1 if the system supports the Software Development Utilities Option, 432otherwise \-1. 433.It Dv _SC_2_UPE 434Return 1 if the system supports the User Portability Utilities Option, 435otherwise \-1. 436.It Dv _SC_2_VERSION 437The version of 438.St -p1003.2 439with which the system attempts to comply. 440.El 441.Pp 442These values also exist, but may not be standard: 443.Bl -tag -width 6n 444.It Dv _SC_LEVEL1_DCACHE_LINESIZE 445Returns the L1 cache line size. 446.It Dv _SC_NPROCESSORS_CONF 447The number of processors configured. 448.It Dv _SC_NPROCESSORS_ONLN 449The number of processors online. 450.It Dv _SC_PHYS_PAGES 451The number of pages of physical memory. 452.El 453.Sh RETURN VALUES 454If the call to 455.Fn sysconf 456is not successful, \-1 is returned and 457.Va errno 458is set appropriately. 459Otherwise, if the variable is associated with functionality that is not 460supported, \-1 is returned and 461.Va errno 462is not modified. 463Otherwise, the current variable value is returned. 464.Pp 465Because \-1 is a valid return value upon success, applications wishing 466to check for real error conditions should set 467.Va errno 468to 0, then call 469.Fn sysconf , 470and check 471.Va errno 472if \-1 is returned. 473.Sh ERRORS 474The 475.Fn sysconf 476function may fail and set 477.Va errno 478for any of the errors specified for the library function 479.Xr sysctl 3 . 480In addition, the following error may be reported: 481.Bl -tag -width Er 482.It Bq Er EINVAL 483The value of the 484.Fa name 485argument is invalid. 486.El 487.Sh SEE ALSO 488.Xr getconf 1 , 489.Xr pathconf 2 , 490.Xr confstr 3 , 491.Xr sysctl 3 492.Sh STANDARDS 493Except for the fact that values returned by 494.Fn sysconf 495may change over the lifetime of the calling process, 496this function conforms to 497.St -p1003.1-88 . 498.Pp 499.Dv _SC_NPROCESSORS_CONF 500and 501.Dv _SC_NPROCESSORS_ONLN 502are nonstandard, but implemented in many systems. 503.Sh HISTORY 504The 505.Fn sysconf 506function first appeared in 507.Bx 4.4 . 508