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 15, 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 maximum number of streams that a process may have open at any one time. 218.It Dv _SC_SYMLOOP_MAX 219Maximum number of symbolic links that can be reliably traversed in the 220resolution of a pathname in the absence of a loop. 221.It Dv _SC_SYNCHRONIZED_IO 222Return 1 if the Synchronized I/O Option is available on this system, 223otherwise \-1. 224.It Dv _SC_THREAD_CPUTIME 225The 226.Dv CLOCK_THREAD_CPUTIME_ID 227clock ID is supported, otherwise \-1. 228.It Dv _SC_THREAD_PRIO_PROTECT 229Whether the system supports the priority ceiling protocol for POSIX threads. 230.It Dv _SC_THREADS 231The version of 232.St -p1003.1 233and its 234Threads 235option to which the system attempts to conform, 236otherwise \-1. 237.It Dv _SC_THREAD_SAFE_FUNCTIONS 238The level of support for thread-safe (re-entrant) functions. 239.It Dv _SC_THREAD_STACK_MIN 240Minimum size in bytes of thread stack storage. 241.It Dv _SC_THREAD_THREADS_MAX 242Maximum number of threads that can be created per process. 243.It Dv _SC_TIMER_MAX 244Maximum number of timers per process supported. 245.It Dv _SC_TIMERS 246The version of 247.St -p1003.1 248and its 249Timers 250option to which the system attempts to conform, 251otherwise \-1. 252.It Dv _SC_TTY_NAME_MAX 253Maximum length of terminal device name. 254.It Dv _SC_TZNAME_MAX 255The maximum number of bytes supported for the name of a timezone. 256.It Dv _SC_VERSION 257The version of 258.St -p1003.1 259with which the system 260attempts to comply. 261.It Dv _SC_XOPEN_SHM 262Return 1 if the system supports the 263.St -xpg4.2 264Shared Memory Feature 265for both compilation and execution, or 0 if only compilation support is 266guaranteed. 267.It Dv _SC_XOPEN_VERSION 268An integer value greater than or equal to 4, 269indicating the version of the X/Open Portability Guide to which this 270system conforms. 271.It Dv _SC_2_C_BIND 272Return 1 if the system's C-language development facilities support the 273C-Language Bindings Option, otherwise \-1. 274.It Dv _SC_2_C_DEV 275Return 1 if the system supports the C-Language Development Utilities Option, 276otherwise \-1. 277.It Dv _SC_2_CHAR_TERM 278Return 1 if the system supports at least one terminal type capable of 279all operations described in 280.St -p1003.2 , 281otherwise \-1. 282.It Dv _SC_2_FORT_DEV 283Return 1 if the system supports the FORTRAN Development Utilities Option, 284otherwise \-1. 285.It Dv _SC_2_FORT_RUN 286Return 1 if the system supports the FORTRAN Runtime Utilities Option, 287otherwise \-1. 288.It Dv _SC_2_LOCALEDEF 289Return 1 if the system supports the creation of locales, otherwise \-1. 290.It Dv _SC_2_SW_DEV 291Return 1 if the system supports the Software Development Utilities Option, 292otherwise \-1. 293.It Dv _SC_2_UPE 294Return 1 if the system supports the User Portability Utilities Option, 295otherwise \-1. 296.It Dv _SC_2_VERSION 297The version of 298.St -p1003.2 299with which the system attempts to comply. 300.El 301.Pp 302These values also exist, but may not be standard: 303.Bl -tag -width 6n 304.It Dv _SC_LEVEL1_DCACHE_LINESIZE 305Returns the L1 cache line size. 306.It Dv _SC_NPROCESSORS_CONF 307The number of processors configured. 308.It Dv _SC_NPROCESSORS_ONLN 309The number of processors online. 310.It Dv _SC_PHYS_PAGES 311The number of pages of physical memory. 312.El 313.Sh RETURN VALUES 314If the call to 315.Fn sysconf 316is not successful, \-1 is returned and 317.Va errno 318is set appropriately. 319Otherwise, if the variable is associated with functionality that is not 320supported, \-1 is returned and 321.Va errno 322is not modified. 323Otherwise, the current variable value is returned. 324.Pp 325Because \-1 is a valid return value upon success, applications wishing 326to check for real error conditions should set 327.Va errno 328to 0, then call 329.Fn sysconf , 330and check 331.Va errno 332if \-1 is returned. 333.Sh ERRORS 334The 335.Fn sysconf 336function may fail and set 337.Va errno 338for any of the errors specified for the library function 339.Xr sysctl 3 . 340In addition, the following error may be reported: 341.Bl -tag -width Er 342.It Bq Er EINVAL 343The value of the 344.Fa name 345argument is invalid. 346.El 347.Sh SEE ALSO 348.Xr getconf 1 , 349.Xr pathconf 2 , 350.Xr confstr 3 , 351.Xr sysctl 3 352.Sh STANDARDS 353Except for the fact that values returned by 354.Fn sysconf 355may change over the lifetime of the calling process, 356this function conforms to 357.St -p1003.1-88 . 358.Pp 359.Dv _SC_NPROCESSORS_CONF 360and 361.Dv _SC_NPROCESSORS_ONLN 362are nonstandard, but implemented in many systems. 363.Sh HISTORY 364The 365.Fn sysconf 366function first appeared in 367.Bx 4.4 . 368