xref: /freebsd/lib/libc/gen/sysconf.3 (revision 4b9d605768acabc460aa6dcfe8a1f8db35b16794)
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.Dd April 26, 2013
29.Dt SYSCONF 3
30.Os
31.Sh NAME
32.Nm sysconf
33.Nd get configurable system variables
34.Sh LIBRARY
35.Lb libc
36.Sh SYNOPSIS
37.In 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.In unistd.h .
55Shell programmers who need access to these parameters should use the
56.Xr getconf 1
57utility.
58.Pp
59The available values are as follows:
60.Bl -tag -width 6n
61.It Li _SC_ARG_MAX
62The maximum bytes of argument to
63.Xr execve 2 .
64.It Li _SC_CHILD_MAX
65The maximum number of simultaneous processes per user id.
66.It Li _SC_CLK_TCK
67The frequency of the statistics clock in ticks per second.
68.It Li _SC_IOV_MAX
69The maximum number of elements in the I/O vector used by
70.Xr readv 2 ,
71.Xr writev 2 ,
72.Xr recvmsg 2 ,
73and
74.Xr sendmsg 2 .
75.It Li _SC_NGROUPS_MAX
76The maximum number of supplemental groups.
77.It Li _SC_NPROCESSORS_CONF
78The number of processors configured.
79.It Li _SC_NPROCESSORS_ONLN
80The number of processors currently online.
81.It Li _SC_OPEN_MAX
82One more than the maximum value the system may assign to a new file descriptor.
83.It Li _SC_PAGESIZE
84The size of a system page in bytes.
85.It Li _SC_PAGE_SIZE
86Equivalent to
87.Li _SC_PAGESIZE .
88.It Li _SC_STREAM_MAX
89The minimum maximum number of streams that a process may have open
90at any one time.
91.It Li _SC_TZNAME_MAX
92The minimum maximum number of types supported for the name of a
93timezone.
94.It Li _SC_JOB_CONTROL
95Return 1 if job control is available on this system, otherwise \-1.
96.It Li _SC_SAVED_IDS
97Returns 1 if saved set-group and saved set-user ID is available,
98otherwise \-1.
99.It Li _SC_VERSION
100The version of
101.St -p1003.1
102with which the system
103attempts to comply.
104.It Li _SC_BC_BASE_MAX
105The maximum ibase/obase values in the
106.Xr bc 1
107utility.
108.It Li _SC_BC_DIM_MAX
109The maximum array size in the
110.Xr bc 1
111utility.
112.It Li _SC_BC_SCALE_MAX
113The maximum scale value in the
114.Xr bc 1
115utility.
116.It Li _SC_BC_STRING_MAX
117The maximum string length in the
118.Xr bc 1
119utility.
120.It Li _SC_COLL_WEIGHTS_MAX
121The maximum number of weights that can be assigned to any entry of
122the LC_COLLATE order keyword in the locale definition file.
123.It Li _SC_EXPR_NEST_MAX
124The maximum number of expressions that can be nested within
125parenthesis by the
126.Xr expr 1
127utility.
128.It Li _SC_LINE_MAX
129The maximum length in bytes of a text-processing utility's input
130line.
131.It Li _SC_RE_DUP_MAX
132The maximum number of repeated occurrences of a regular expression
133permitted when using interval notation.
134.It Li _SC_2_VERSION
135The version of
136.St -p1003.2
137with which the system attempts to comply.
138.It Li _SC_2_C_BIND
139Return 1 if the system's C-language development facilities support the
140C-Language Bindings Option, otherwise \-1.
141.It Li _SC_2_C_DEV
142Return 1 if the system supports the C-Language Development Utilities Option,
143otherwise \-1.
144.It Li _SC_2_CHAR_TERM
145Return 1 if the system supports at least one terminal type capable of
146all operations described in
147.St -p1003.2 ,
148otherwise \-1.
149.It Li _SC_2_FORT_DEV
150Return 1 if the system supports the FORTRAN Development Utilities Option,
151otherwise \-1.
152.It Li _SC_2_FORT_RUN
153Return 1 if the system supports the FORTRAN Runtime Utilities Option,
154otherwise \-1.
155.It Li _SC_2_LOCALEDEF
156Return 1 if the system supports the creation of locales, otherwise \-1.
157.It Li _SC_2_SW_DEV
158Return 1 if the system supports the Software Development Utilities Option,
159otherwise \-1.
160.It Li _SC_2_UPE
161Return 1 if the system supports the User Portability Utilities Option,
162otherwise \-1.
163.It Li _SC_AIO_LISTIO_MAX
164Maximum number of I/O operations in a single list I/O call supported.
165.It Li _SC_AIO_MAX
166Maximum number of outstanding asynchronous I/O operations supported.
167.It Li _SC_AIO_PRIO_DELTA_MAX
168The maximum amount by which a process can decrease its asynchronous I/O
169priority level from its own scheduling priority.
170.It Li _SC_DELAYTIMER_MAX
171Maximum number of timer expiration overruns.
172.It Li _SC_MQ_OPEN_MAX
173The maximum number of open message queue descriptors a process may hold.
174.It Li _SC_RTSIG_MAX
175Maximum number of realtime signals reserved for application use.
176.It Li _SC_SEM_NSEMS_MAX
177Maximum number of semaphores that a process may have.
178.It Li _SC_SEM_VALUE_MAX
179The maximum value a semaphore may have.
180.It Li _SC_SIGQUEUE_MAX
181Maximum number of queued signals that a process may send and have pending at
182the receiver(s) at any time.
183.It Li _SC_TIMER_MAX
184Maximum number of timers per process supported.
185.It Li _SC_GETGR_R_SIZE_MAX
186Suggested initial value for the size of the group entry buffer.
187.It Li _SC_GETPW_R_SIZE_MAX
188Suggested initial value for the size of the password entry buffer.
189.It Li _SC_HOST_NAME_MAX
190Maximum length of a host name (not including the terminating null) as
191returned from the
192.Fn gethostname
193function.
194.It Li _SC_LOGIN_NAME_MAX
195Maximum length of a login name.
196.It Li _SC_THREAD_STACK_MIN
197Minimum size in bytes of thread stack storage.
198.It Li _SC_THREAD_THREADS_MAX
199Maximum number of threads that can be created per process.
200.It Li _SC_TTY_NAME_MAX
201Maximum length of terminal device name.
202.It Li _SC_SYMLOOP_MAX
203Maximum number of symbolic links that can be reliably traversed in the
204resolution of a pathname in the absence of a loop.
205.It Li _SC_ATEXIT_MAX
206Maximum number of functions that may be registered with
207.Fn atexit .
208.It Li _SC_XOPEN_VERSION
209An integer value greater than or equal to 4,
210indicating the version of the X/Open Portability Guide to which this
211system conforms.
212.It Li _SC_XOPEN_XCU_VERSION
213An integer value indicating the version of the XCU Specification to which
214this system conforms.
215.El
216.Pp
217These values also exist, but may not be standard:
218.Bl -tag -width 6n
219.It Li _SC_CPUSET_SIZE
220Size of the kernel cpuset.
221.It Li _SC_PHYS_PAGES
222The number of pages of physical memory.
223Note that it is possible that the product of this value and the value of
224.Li _SC_PAGESIZE
225will overflow a
226.Vt long
227in some configurations on a 32bit machine.
228.El
229.Sh RETURN VALUES
230If the call to
231.Fn sysconf
232is not successful, \-1 is returned and
233.Va errno
234is set appropriately.
235Otherwise, if the variable is associated with functionality that is not
236supported, \-1 is returned and
237.Va errno
238is not modified.
239Otherwise, the current variable value is returned.
240.Sh ERRORS
241The
242.Fn sysconf
243function may fail and set
244.Va errno
245for any of the errors specified for the library function
246.Xr sysctl 3 .
247In addition, the following error may be reported:
248.Bl -tag -width Er
249.It Bq Er EINVAL
250The value of the
251.Fa name
252argument is invalid.
253.El
254.Sh SEE ALSO
255.Xr getconf 1 ,
256.Xr pathconf 2 ,
257.Xr confstr 3 ,
258.Xr sysctl 3
259.Sh STANDARDS
260Except for the fact that values returned by
261.Fn sysconf
262may change over the lifetime of the calling process,
263this function conforms to
264.St -p1003.1-88 .
265.Sh HISTORY
266The
267.Fn sysconf
268function first appeared in
269.Bx 4.4 .
270.Sh BUGS
271The value for _SC_STREAM_MAX is a minimum maximum, and required to be
272the same as ANSI C's FOPEN_MAX, so the returned value is a ridiculously
273small and misleading number.
274