1.\"	$OpenBSD: sysconf.3,v 1.35 2019/08/11 15:48:08 deraadt 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.Dd $Mdocdate: August 11 2019 $
31.Dt SYSCONF 3
32.Os
33.Sh NAME
34.Nm sysconf
35.Nd get configurable system variables
36.Sh SYNOPSIS
37.In unistd.h
38.Ft long
39.Fn sysconf "int name"
40.Sh DESCRIPTION
41The
42.Fn sysconf
43function provides a method for applications to determine the current
44value of a configurable system limit or option variable.
45The
46.Fa name
47argument specifies the system variable to be queried.
48Symbolic constants for each name value are found in the include file
49.In unistd.h .
50.Pp
51The available values are as follows:
52.Bl -tag -width "123456"
53.It Li _SC_ARG_MAX
54The maximum bytes of arguments to
55.Xr execve 2
56(including the environment).
57.It Li _SC_CHILD_MAX
58The maximum number of simultaneous processes per user ID.
59.It Li _SC_CLK_TCK
60The number of clock ticks per second.
61.It Li _SC_NGROUPS_MAX
62The maximum number of supplemental groups.
63.It Li _SC_OPEN_MAX
64The maximum number of open files per user ID.
65.It Li _SC_STREAM_MAX
66The minimum maximum number of streams that a process may have open
67at any one time.
68.It Li _SC_TZNAME_MAX
69The minimum maximum number of types supported for the name of a
70time zone.
71.It Li _SC_JOB_CONTROL
72Returns 1 if job control is available on this system, otherwise \-1.
73.It Li _SC_SAVED_IDS
74Returns 1 if saved set-group-ID and saved set-user-ID is available,
75otherwise \-1.
76.It Li _SC_VERSION
77The version of ISO/IEC 9945 (POSIX 1003.1) with which the system
78attempts to comply.
79.It Li _SC_BC_BASE_MAX
80The maximum ibase/obase values in the
81.Xr bc 1
82utility.
83.It Li _SC_BC_DIM_MAX
84The maximum array size in the
85.Xr bc 1
86utility.
87.It Li _SC_BC_SCALE_MAX
88The maximum scale value in the
89.Xr bc 1
90utility.
91.It Li _SC_BC_STRING_MAX
92The maximum string length in the
93.Xr bc 1
94utility.
95.It Li _SC_COLL_WEIGHTS_MAX
96The maximum number of weights that can be assigned to any entry of
97the LC_COLLATE order keyword in the locale definition file.
98.It Li _SC_EXPR_NEST_MAX
99The maximum number of expressions that can be nested within
100parentheses by the
101.Xr expr 1
102utility.
103.It Li _SC_LINE_MAX
104The maximum length in bytes of a text-processing utility's input
105line.
106.It Li _SC_RE_DUP_MAX
107The maximum number of repeated occurrences of a regular expression
108permitted when using interval notation.
109.It Li _SC_2_VERSION
110The version of POSIX 1003.2 with which the system attempts to comply.
111.It Li _SC_2_C_BIND
112Return 1 if the system's C-language development facilities support the
113C-Language Bindings Option, otherwise \-1.
114.It Li _SC_2_C_DEV
115Return 1 if the system supports the C-Language Development Utilities Option,
116otherwise \-1.
117.It Li _SC_2_CHAR_TERM
118Return 1 if the system supports at least one terminal type capable of
119all operations described in POSIX 1003.2, otherwise \-1.
120.It Li _SC_2_FORT_DEV
121Return 1 if the system supports the FORTRAN Development Utilities Option,
122otherwise \-1.
123.It Li _SC_2_FORT_RUN
124Return 1 if the system supports the FORTRAN Runtime Utilities Option,
125otherwise \-1.
126.It Li _SC_2_LOCALEDEF
127Return 1 if the system supports the creation of locales, otherwise \-1.
128.It Li _SC_2_SW_DEV
129Return 1 if the system supports the Software Development Utilities Option,
130otherwise \-1.
131.It Li _SC_2_UPE
132Return 1 if the system supports the User Portability Utilities Option,
133otherwise \-1.
134.It Li _SC_PAGESIZE
135The size of a system page in bytes.
136.It Li _SC_FSYNC
137Return 1 if the system supports the File Synchronisation Option, otherwise \-1.
138.It Li _SC_XOPEN_SHM
139Return 1 if the system supports the Shared Memory Option, otherwise \-1.
140.It Li _SC_SEM_NSEMS_MAX
141The maximum number of semaphores in the system or \-1 if the system
142does not support the Semaphores Option.
143.It Li _SC_SEM_VALUE_MAX
144The maximum value a semaphore may have or \-1 if the system
145does not support the Semaphores Option.
146.It Li _SC_PHYS_PAGES
147The number of pages of physical memory.
148.It Li _SC_AVPHYS_PAGES
149The number of pages of physical memory not currently in use by the system.
150.It Li _SC_GETGR_R_SIZE_MAX
151The maximum size of the data buffer for the
152.Fn getgrgid_r
153and
154.Fn getgrnam_r
155functions.
156.It Li _SC_GETPW_R_SIZE_MAX
157The maximum size of the data buffer for the
158.Fn getpwuid_r
159and
160.Fn getpwnam_r
161functions.
162.It Li _SC_LOGIN_NAME_MAX
163The maximum length of a login name.
164.It Li _SC_THREAD_SAFE_FUNCTIONS
165The level of support for thread-safe (re-entrant) functions.
166.It Li _SC_NPROCESSORS_CONF
167The number of processors configured.
168.It Li _SC_NPROCESSORS_ONLN
169The number of processors online (capable of running processes).
170.It Li _SC_HOST_NAME_MAX
171The maximum size of a hostname, not counting NULL.
172.It Li _SC_MONOTONIC_CLOCK
173Return the POSIX version of the implementation of the Monotonic Clock
174option that this system conforms to, or \-1 if unavailable.
175.El
176.Sh RETURN VALUES
177If the call to
178.Fn sysconf
179is not successful, \-1 is returned and
180.Va errno
181is set appropriately.
182Otherwise, if the variable is associated with functionality that is not
183supported, \-1 is returned and
184.Va errno
185is not modified.
186Otherwise, the current variable value is returned.
187.Sh ERRORS
188The
189.Fn sysconf
190function may fail and set
191.Va errno
192for any of the errors specified for the library function
193.Xr sysctl 2 .
194In addition, the following error may be reported:
195.Bl -tag -width Er
196.It Bq Er EINVAL
197The value of the
198.Fa name
199argument is invalid.
200.El
201.Sh SEE ALSO
202.Xr pathconf 2 ,
203.Xr sysctl 2
204.Sh STANDARDS
205The
206.Fn sysconf
207function conforms to
208.St -p1003.1-88 .
209The constants
210.Li _SC_NPROCESSORS_CONF
211and
212.Li _SC_NPROCESSORS_ONLN
213are not part of the standard, but are provided by many systems.
214.Sh HISTORY
215The
216.Fn sysconf
217function first appeared in
218.Bx 4.4 .
219.Sh BUGS
220The value for _SC_STREAM_MAX is a minimum maximum, and required to be
221the same as ANSI C's FOPEN_MAX, so the returned value is a ridiculously
222small and misleading number.
223