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