xref: /openbsd/lib/libc/gen/sysconf.3 (revision 8932bfb7)
1.\"	$OpenBSD: sysconf.3,v 1.28 2010/10/28 02:06:00 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: October 28 2010 $
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.El
178.Sh RETURN VALUES
179If the call to
180.Fn sysconf
181is not successful, \-1 is returned and
182.Va errno
183is set appropriately.
184Otherwise, if the variable is associated with functionality that is not
185supported, \-1 is returned and
186.Va errno
187is not modified.
188Otherwise, the current variable value is returned.
189.Sh ERRORS
190The
191.Fn sysconf
192function may fail and set
193.Va errno
194for any of the errors specified for the library function
195.Xr sysctl 3 .
196In addition, the following error may be reported:
197.Bl -tag -width Er
198.It Bq Er EINVAL
199The value of the
200.Fa name
201argument is invalid.
202.El
203.Sh SEE ALSO
204.Xr pathconf 2 ,
205.Xr sysctl 3
206.Sh STANDARDS
207The
208.Fn sysconf
209function conforms to
210.St -p1003.1-88 .
211The constants
212.Li _SC_NPROCESSORS_CONF
213and
214.Li _SC_NPROCESSORS_ONLN
215are not part of the standard, but are provided by many systems.
216.Sh HISTORY
217The
218.Fn sysconf
219function first appeared in
220.Bx 4.4 .
221.Sh BUGS
222The value for _SC_STREAM_MAX is a minimum maximum, and required to be
223the same as ANSI C's FOPEN_MAX, so the returned value is a ridiculously
224small and misleading number.
225