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 June 13, 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_AIO_LISTIO_MAX 62Maximum number of I/O operations in a single list I/O call supported. 63.It Dv _SC_AIO_MAX 64Maximum number of outstanding asynchronous I/O operations supported. 65.It Dv _SC_AIO_PRIO_DELTA_MAX 66The maximum amount by which a process can decrease its asynchronous I/O 67priority level from its own scheduling priority. 68.It Dv _SC_ARG_MAX 69The maximum bytes of argument to 70.Xr execve 2 . 71.It Dv _SC_ATEXIT_MAX 72Maximum number of functions that may be registered with 73.Fn atexit . 74.It Dv _SC_BARRIERS 75The version of 76.St -p1003.1 77and its 78Barriers 79option to which the system attempts to conform, 80otherwise \-1. 81.It Dv _SC_BC_BASE_MAX 82The maximum ibase/obase values in the 83.Xr bc 1 84utility. 85.It Dv _SC_BC_DIM_MAX 86The maximum array size in the 87.Xr bc 1 88utility. 89.It Dv _SC_BC_SCALE_MAX 90The maximum scale value in the 91.Xr bc 1 92utility. 93.It Dv _SC_BC_STRING_MAX 94The maximum string length in the 95.Xr bc 1 96utility. 97.It Dv _SC_CHILD_MAX 98The maximum number of simultaneous processes per user id. 99.It Dv _SC_CLK_TCK 100The frequency of the statistics clock in ticks per second. 101.It Dv _SC_CLOCK_SELECTION 102Return the POSIX version the implementation of the Clock Selection Option 103on this system conforms to, or \-1 if unavailable. 104.It Dv _SC_COLL_WEIGHTS_MAX 105The maximum number of weights that can be assigned to any entry of 106the LC_COLLATE order keyword in the locale definition file. 107.It Dv _SC_CPUTIME 108The 109.Dv CLOCK_PROCESS_CPUTIME_ID 110clock ID is supported, otherwise \-1. 111.It Dv _SC_DELAYTIMER_MAX 112Maximum number of timer expiration overruns. 113.It Dv _SC_EXPR_NEST_MAX 114The maximum number of expressions that can be nested within 115parenthesis by the 116.Xr expr 1 117utility. 118.It Dv _SC_FSYNC 119Return 1 if the File Synchronization Option is available on this system, 120otherwise \-1. 121.It Dv _SC_GETGR_R_SIZE_MAX 122Suggested initial value for the size of the group entry buffer. 123.It Dv _SC_GETPW_R_SIZE_MAX 124Suggested initial value for the size of the password entry buffer. 125.It Dv _SC_HOST_NAME_MAX 126Maximum length of a host name (not including the terminating null) as 127returned from the 128.Xr gethostname 3 , 129function. 130.It Dv _SC_IOV_MAX 131The maximum number of elements in the I/O vector used by 132.Xr readv 2 , 133.Xr writev 2 , 134.Xr recvmsg 2 , 135and 136.Xr sendmsg 2 . 137.It Dv _SC_JOB_CONTROL 138Return 1 if job control is available on this system, otherwise \-1. 139.It Dv _SC_LINE_MAX 140The maximum length in bytes of a text-processing utility's input 141line. 142.It Dv _SC_LOGIN_NAME_MAX 143Maximum length of a login name. 144.It Dv _SC_MAPPED_FILES 145Return 1 if the Memory Mapped Files Option is available on this system, 146otherwise \-1. 147.It Dv _SC_MEMLOCK 148Return 1 if the Process Memory Locking Option is available on this system, 149otherwise \-1. 150.It Dv _SC_MEMLOCK_RANGE 151Return 1 if the Range Memory Locking Option is available on this system, 152otherwise \-1. 153.It Dv _SC_MEMORY_PROTECTION 154Return 1 if the Memory Protection Option is available on this system, 155otherwise \-1. 156.It Dv _SC_MESSAGE_PASSING 157Whether Message Passing option is supported. 158.It Dv _SC_MONOTONIC_CLOCK 159Return the POSIX version of the implementation of the Monotonic Clock 160option that this system conforms to, or \-1 if unavailable. 161.It Dv _SC_MQ_OPEN_MAX 162The maximum number of open message queue descriptors per process. 163.It Dv _SC_MQ_PRIO_MAX 164The maximum number of message priorities supported by the implementation. 165.It Dv _SC_NGROUPS_MAX 166The maximum number of supplemental groups. 167.It Dv _SC_OPEN_MAX 168The maximum number of open files per user id. 169.It Dv _SC_PAGESIZE 170The size of a system page in bytes. 171.It Dv _SC_PAGE_SIZE 172Equivalent to 173.Dv _SC_PAGESIZE . 174.It Dv _SC_READER_WRITER_LOCKS 175The version of 176.St -p1003.1 177and its 178Read-Write Locks 179option to which the system attempts to conform, 180otherwise \-1. 181.It Dv _SC_RE_DUP_MAX 182The maximum number of repeated occurrences of a regular expression 183permitted when using interval notation. 184.It Dv _SC_REGEXP 185Return 1 if the system supports regular expression handling. 186.It Dv _SC_RTSIG_MAX 187Maximum number of realtime signals reserved for application use. 188.It Dv _SC_SAVED_IDS 189Return 1 if saved set-group and saved set-user ID is available, 190otherwise \-1. 191.It Dv _SC_SEMAPHORES 192The version of 193.St -p1003.1 194and its 195Semaphores 196option to which the system attempts to conform, 197otherwise \-1. 198.It Dv _SC_SEM_NSEMS_MAX 199Maximum number of semaphores that a process may have. 200.It Dv _SC_SEM_VALUE_MAX 201The maximum value a semaphore may have. 202.It Dv _SC_SHELL 203Return 1 if the system supports the 204.Tn POSIX 205shell. 206.It Dv _SC_SIGQUEUE_MAX 207Maximum number of queued signals that a process may send and have pending at 208the receiver(s) at any time. 209.It Dv _SC_SPIN_LOCKS 210The version of 211.St -p1003.1 212and its 213Spin Locks 214option to which the system attempts to conform, 215otherwise \-1. 216.It Dv _SC_STREAM_MAX 217The minimum maximum number of streams that a process may have open 218at any one time. 219.It Dv _SC_SYMLOOP_MAX 220Maximum number of symbolic links that can be reliably traversed in the 221resolution of a pathname in the absence of a loop. 222.It Dv _SC_SYNCHRONIZED_IO 223Return 1 if the Synchronized I/O Option is available on this system, 224otherwise \-1. 225.It Dv _SC_THREAD_CPUTIME 226The 227.Dv CLOCK_THREAD_CPUTIME_ID 228clock ID is supported, otherwise \-1. 229.It Dv _SC_THREAD_PRIO_PROTECT 230Whether the system supports the priority ceiling protocol for POSIX threads. 231.It Dv _SC_THREADS 232The version of 233.St -p1003.1 234and its 235Threads 236option to which the system attempts to conform, 237otherwise \-1. 238.It Dv _SC_THREAD_SAFE_FUNCTIONS 239The level of support for thread-safe (re-entrant) functions. 240.It Dv _SC_THREAD_STACK_MIN 241Minimum size in bytes of thread stack storage. 242.It Dv _SC_THREAD_THREADS_MAX 243Maximum number of threads that can be created per process. 244.It Dv _SC_TIMER_MAX 245Maximum number of timers per process supported. 246.It Dv _SC_TIMERS 247The version of 248.St -p1003.1 249and its 250Timers 251option to which the system attempts to conform, 252otherwise \-1. 253.It Dv _SC_TTY_NAME_MAX 254Maximum length of terminal device name. 255.It Dv _SC_TZNAME_MAX 256The minimum maximum number of types supported for the name of a 257timezone. 258.It Dv _SC_VERSION 259The version of 260.St -p1003.1 261with which the system 262attempts to comply. 263.It Dv _SC_XOPEN_SHM 264Return 1 if the system supports the 265.St -xpg4.2 266Shared Memory Feature 267for both compilation and execution, or 0 if only compilation support is 268guaranteed. 269.It Dv _SC_XOPEN_VERSION 270An integer value greater than or equal to 4, 271indicating the version of the X/Open Portability Guide to which this 272system conforms. 273.It Dv _SC_2_C_BIND 274Return 1 if the system's C-language development facilities support the 275C-Language Bindings Option, otherwise \-1. 276.It Dv _SC_2_C_DEV 277Return 1 if the system supports the C-Language Development Utilities Option, 278otherwise \-1. 279.It Dv _SC_2_CHAR_TERM 280Return 1 if the system supports at least one terminal type capable of 281all operations described in 282.St -p1003.2 , 283otherwise \-1. 284.It Dv _SC_2_FORT_DEV 285Return 1 if the system supports the FORTRAN Development Utilities Option, 286otherwise \-1. 287.It Dv _SC_2_FORT_RUN 288Return 1 if the system supports the FORTRAN Runtime Utilities Option, 289otherwise \-1. 290.It Dv _SC_2_LOCALEDEF 291Return 1 if the system supports the creation of locales, otherwise \-1. 292.It Dv _SC_2_SW_DEV 293Return 1 if the system supports the Software Development Utilities Option, 294otherwise \-1. 295.It Dv _SC_2_UPE 296Return 1 if the system supports the User Portability Utilities Option, 297otherwise \-1. 298.It Dv _SC_2_VERSION 299The version of 300.St -p1003.2 301with which the system attempts to comply. 302.El 303.Pp 304These values also exist, but may not be standard: 305.Bl -tag -width 6n 306.It Dv _SC_LEVEL1_DCACHE_LINESIZE 307Returns the L1 cache line size. 308.It Dv _SC_NPROCESSORS_CONF 309The number of processors configured. 310.It Dv _SC_NPROCESSORS_ONLN 311The number of processors online. 312.It Dv _SC_PHYS_PAGES 313The number of pages of physical memory. 314.El 315.Sh RETURN VALUES 316If the call to 317.Fn sysconf 318is not successful, \-1 is returned and 319.Va errno 320is set appropriately. 321Otherwise, if the variable is associated with functionality that is not 322supported, \-1 is returned and 323.Va errno 324is not modified. 325Otherwise, the current variable value is returned. 326.Sh ERRORS 327The 328.Fn sysconf 329function may fail and set 330.Va errno 331for any of the errors specified for the library function 332.Xr sysctl 3 . 333In addition, the following error may be reported: 334.Bl -tag -width Er 335.It Bq Er EINVAL 336The value of the 337.Fa name 338argument is invalid. 339.El 340.Sh SEE ALSO 341.Xr getconf 1 , 342.Xr pathconf 2 , 343.Xr confstr 3 , 344.Xr sysctl 3 345.Sh STANDARDS 346Except for the fact that values returned by 347.Fn sysconf 348may change over the lifetime of the calling process, 349this function conforms to 350.St -p1003.1-88 . 351.Pp 352.Dv _SC_NPROCESSORS_CONF 353and 354.Dv _SC_NPROCESSORS_ONLN 355are nonstandard, but implemented in many systems. 356.Sh HISTORY 357The 358.Fn sysconf 359function first appeared in 360.Bx 4.4 . 361.Sh BUGS 362The value for 363.Dv _SC_STREAM_MAX 364is a minimum maximum, and required to be the same as ANSI C's 365.Dv FOPEN_MAX , 366so the returned value is a ridiculously small and misleading number. 367