1.\" $NetBSD: sysconf.3,v 1.50 2016/07/05 09:51:10 wiz Exp $ 2.\" 3.\" Copyright (c) 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. Neither the name of the University nor the names of its contributors 15.\" may be used to endorse or promote products derived from this software 16.\" without specific prior written permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.\" @(#)sysconf.3 8.3 (Berkeley) 4/19/94 31.\" 32.Dd July 3, 2016 33.Dt SYSCONF 3 34.Os 35.Sh NAME 36.Nm sysconf 37.Nd get configurable system variables 38.Sh LIBRARY 39.Lb libc 40.Sh SYNOPSIS 41.In unistd.h 42.Ft long 43.Fn sysconf "int name" 44.Sh DESCRIPTION 45This interface is defined by 46.St -p1003.1-88 . 47A far more complete interface is available using 48.Xr sysctl 3 . 49.Pp 50The 51.Fn sysconf 52function provides a method for applications to determine the current 53value of a configurable system limit or option variable. 54The 55.Fa name 56argument specifies the system variable to be queried. 57Symbolic constants for each name value are found in the include file 58.In unistd.h . 59.Pp 60The available values are as follows: 61.Bl -tag -width "123456" 62.It Li _SC_ARG_MAX 63The maximum bytes of argument to 64.Xr execve 2 . 65.It Li _SC_ATEXIT_MAX 66The maximum number of functions that may be registered with 67.Xr atexit 3 . 68.It Li _SC_BARRIERS 69The version of 70.St -p1003.1 71and its 72Barriers 73option to which the system attempts to conform, 74otherwise \-1. 75.It Li _SC_CLOCK_SELECTION 76Return the 77.Tn POSIX 78version the implementation of the Clock Selection Option 79on this system conforms to, 80or \-1 if unavailable. 81.It Li _SC_CHILD_MAX 82The maximum number of simultaneous processes per user id. 83.It Li _SC_CLK_TCK 84The number of clock ticks per second. 85.It Li _SC_FSYNC 86Return 1 if the File Synchronization Option is available on this system, 87otherwise \-1. 88.It Li _SC_HOST_NAME_MAX 89The maximum size of a hostname, including 90.Dv NULL . 91.It Li _SC_IOV_MAX 92The maximum number of 93.Va iovec 94structures that a process has available for use with 95.Xr preadv 2 , 96.Xr pwritev 2 , 97.Xr readv 2 , 98.Xr recvmsg 2 , 99.Xr sendmsg 2 100or 101.Xr writev 2 . 102.It Li _SC_JOB_CONTROL 103Return 1 if job control is available on this system, otherwise \-1. 104.It Li _SC_LOGIN_NAME_MAX 105Returns the size of the storage required for a login name, in bytes, 106including the terminating NUL. 107.It Li _SC_MAPPED_FILES 108Return 1 if the Memory Mapped Files Option is available on this system, 109otherwise \-1. 110.It Li _SC_MEMLOCK 111Return 1 if the Process Memory Locking Option is available on this system, 112otherwise \-1. 113.It Li _SC_MEMLOCK_RANGE 114Return 1 if the Range Memory Locking Option is available on this system, 115otherwise \-1. 116.It Li _SC_MEMORY_PROTECTION 117Return 1 if the Memory Protection Option is available on this system, 118otherwise \-1. 119.It Li _SC_MONOTONIC_CLOCK 120Return the 121.Tn POSIX 122version the implementation of the Monotonic Clock Option 123on this system conforms to, 124or \-1 if unavailable. 125.It Li _SC_NGROUPS_MAX 126The maximum number of supplemental groups. 127.It Li _SC_OPEN_MAX 128The maximum number of open files per process. 129.It Li _SC_PAGESIZE 130The size of a system page in bytes. 131.It Li _SC_PASS_MAX 132The maximum length of the password, not counting 133.Dv NULL . 134.It Li _SC_READER_WRITER_LOCKS 135The version of 136.St -p1003.1 137and its 138Read-Write Locks 139option to which the system attempts to conform, 140otherwise \-1. 141.It Li _SC_REGEXP 142Return 1 if 143.Tn POSIX 144regular expressions are available on this system, otherwise \-1. 145.It Li _SC_SEMAPHORES 146The version of 147.St -p1003.1 148and its 149Semaphores 150option to which the system attempts to conform, 151otherwise \-1. 152.It Li _SC_SEM_NSEMS_MAX 153The maximum number of semaphores that one process can have open at a time, 154otherwise \-1. 155.It Li _SC_SHELL 156Return 1 if 157.Tn POSIX 158shell is available on this system, otherwise \-1. 159.It Li _SC_SPIN_LOCKS 160The version of 161.St -p1003.1 162and its 163Spin Locks 164option to which the system attempts to conform, 165otherwise \-1. 166.It Li _SC_STREAM_MAX 167The minimum maximum number of streams that a process may have open 168at any one time. 169.It Li _SC_SYMLOOP_MAX 170The maximum number of symbolic links that may be expanded in a path name. 171.It Li _SC_SYNCHRONIZED_IO 172Return 1 if the Synchronized I/O Option is available on this system, 173otherwise \-1. 174.It Li _SC_THREADS 175The version of 176.St -p1003.1 177and its 178Threads 179option to which the system attempts to conform, 180otherwise \-1. 181.It Li _SC_THREAD_PRIO_PROTECT 182System supports the priority ceiling protocol for POSIX threads. 183.It Li _SC_TIMERS 184The version of 185.St -p1003.1 186and its 187Timers 188option to which the system attempts to conform, 189otherwise \-1. 190.It Li _SC_CPUTIME 191The clockID CLOCK_PROCESS_CPUTIME_ID is supported, 192otherwise \-1. 193.It Li _SC_THREAD_CPUTIME 194The clockID CLOCK_THREAD_CPUTIME_ID is supported, 195otherwise \-1. 196.It Li _SC_DELAYTIMER_MAX 197The maximum number of overrun for a specific timer, 198otherwise \-1. 199.It Li _SC_TZNAME_MAX 200The minimum maximum number of types supported for the name of a 201timezone. 202.It Li _SC_SAVED_IDS 203Returns 1 if saved set-group and saved set-user ID is available, 204otherwise \-1. 205.It Li _SC_VERSION 206The version of ISO/IEC 9945 (POSIX 1003.1) with which the system 207attempts to comply. 208.It Li _SC_XOPEN_SHM 209Return 1 if the 210.St -xpg4.2 211Shared Memory 212option is available on this system, 213otherwise \-1. 214.Pp 215Availability of the 216Shared Memory 217option depends on the 218.Li SYSVSHM 219kernel option. 220.It Li _SC_BC_BASE_MAX 221The maximum ibase/obase values in the 222.Xr bc 1 223utility. 224.It Li _SC_BC_DIM_MAX 225The maximum array size in the 226.Xr bc 1 227utility. 228.It Li _SC_BC_SCALE_MAX 229The maximum scale value in the 230.Xr bc 1 231utility. 232.It Li _SC_BC_STRING_MAX 233The maximum string length in the 234.Xr bc 1 235utility. 236.It Li _SC_COLL_WEIGHTS_MAX 237The maximum number of weights that can be assigned to any entry of 238the LC_COLLATE order keyword in the locale definition file. 239.It Li _SC_EXPR_NEST_MAX 240The maximum number of expressions that can be nested within 241parenthesis by the 242.Xr expr 1 243utility. 244.It Li _SC_LINE_MAX 245The maximum length in bytes of a text-processing utility's input 246line. 247.It Li _SC_RE_DUP_MAX 248The maximum number of repeated occurrences of a regular expression 249permitted when using interval notation. 250.It Li _SC_2_VERSION 251The version of POSIX 1003.2 with which the system attempts to comply. 252.It Li _SC_2_C_BIND 253Return 1 if the system's C-language development facilities support the 254C-Language Bindings Option, otherwise \-1. 255.It Li _SC_2_C_DEV 256Return 1 if the system supports the C-Language Development Utilities Option, 257otherwise \-1. 258.It Li _SC_2_CHAR_TERM 259Return 1 if the system supports at least one terminal type capable of 260all operations described in POSIX 1003.2, otherwise \-1. 261.It Li _SC_2_FORT_DEV 262Return 1 if the system supports the FORTRAN Development Utilities Option, 263otherwise \-1. 264.It Li _SC_2_FORT_RUN 265Return 1 if the system supports the FORTRAN Runtime Utilities Option, 266otherwise \-1. 267.It Li _SC_2_LOCALEDEF 268Return 1 if the system supports the creation of locales, otherwise \-1. 269.It Li _SC_2_SW_DEV 270Return 1 if the system supports the Software Development Utilities Option, 271otherwise \-1. 272.It Li _SC_2_UPE 273Return 1 if the system supports the User Portability Utilities Option, 274otherwise \-1. 275.It Li _SC_GETGR_R_SIZE_MAX 276The minimum size of the 277.Fa buffer 278passed to 279.Xr getgrgid_r 3 280and 281.Xr getgrnam_r 3 . 282.It Li _SC_GETPW_R_SIZE_MAX 283The minimum size of the 284.Fa buffer 285passed to 286.Xr getpwnam_r 3 287and 288.Xr getpwuid_r 3 . 289.It Li _SC_NPROCESSORS_CONF 290The number of processors configured. 291.It Li _SC_NPROCESSORS_ONLN 292The number of processors online (capable of running processes). 293.It Li _SC_PHYS_PAGES 294The amount of physical memory on the system in 295.Li _SC_PAGESIZE 296bytes. 297.Li _SC_TIMER_MAX 298The number of timers available for 299.Xr timer_create 2 . 300This is also known as 301.Dv _POSIX_TIMER_MAX . 302.El 303.Sh RETURN VALUES 304If the call to 305.Nm sysconf 306is not successful, \-1 is returned and 307.Va errno 308is set appropriately. 309Otherwise, if the variable is associated with functionality that is not 310supported, \-1 is returned and 311.Va errno 312is not modified. 313Otherwise, the current variable value is returned. 314.Sh ERRORS 315The 316.Fn sysconf 317function may fail and set 318.Va errno 319for any of the errors specified for the library functions 320.Xr sysctl 3 . 321In addition, the following error may be reported: 322.Bl -tag -width Er 323.It Bq Er EINVAL 324The value of the 325.Fa name 326argument is invalid. 327.El 328.Sh SEE ALSO 329.Xr getconf 1 , 330.Xr limits 3 , 331.Xr sysctl 3 332.Sh STANDARDS 333The 334.Fn sysconf 335function conforms to 336.St -p1003.1-90 . 337The constants 338.Li _SC_NPROCESSORS_CONF 339and 340.Li _SC_NPROCESSORS_ONLN 341are not part of the standard, but are provided by many systems. 342.Sh HISTORY 343The 344.Nm sysconf 345function first appeared in 346.Bx 4.4 . 347.Sh BUGS 348The value for _SC_STREAM_MAX is a minimum maximum, and required to be 349the same as ANSI C's FOPEN_MAX, so the returned value is a ridiculously 350small and misleading number. 351