1SYSCONF(P) POSIX Programmer's Manual SYSCONF(P)
2
3
4
6 sysconf - get configurable system variables
7
9 #include <unistd.h>
10
11 long sysconf(int name);
12
13
15 The sysconf() function provides a method for the application to deter‐
16 mine the current value of a configurable system limit or option ( vari‐
17 able). The implementation shall support all of the variables listed in
18 the following table and may support others.
19
20 The name argument represents the system variable to be queried. The
21 following table lists the minimal set of system variables from <lim‐
22 its.h> or <unistd.h> that can be returned by sysconf(), and the sym‐
23 bolic constants defined in <unistd.h> that are the corresponding values
24 used for name.
25
26 Variable Value of Name
27 {AIO_LISTIO_MAX} _SC_AIO_LISTIO_MAX
28 {AIO_MAX} _SC_AIO_MAX
29 {AIO_PRIO_DELTA_MAX} _SC_AIO_PRIO_DELTA_MAX
30 {ARG_MAX} _SC_ARG_MAX
31 {ATEXIT_MAX} _SC_ATEXIT_MAX
32 {BC_BASE_MAX} _SC_BC_BASE_MAX
33 {BC_DIM_MAX} _SC_BC_DIM_MAX
34 {BC_SCALE_MAX} _SC_BC_SCALE_MAX
35 {BC_STRING_MAX} _SC_BC_STRING_MAX
36 {CHILD_MAX} _SC_CHILD_MAX
37 Clock ticks/second _SC_CLK_TCK
38 {COLL_WEIGHTS_MAX} _SC_COLL_WEIGHTS_MAX
39 {DELAYTIMER_MAX} _SC_DELAYTIMER_MAX
40 {EXPR_NEST_MAX} _SC_EXPR_NEST_MAX
41 {HOST_NAME_MAX} _SC_HOST_NAME_MAX
42 {IOV_MAX} _SC_IOV_MAX
43 {LINE_MAX} _SC_LINE_MAX
44 {LOGIN_NAME_MAX} _SC_LOGIN_NAME_MAX
45 {NGROUPS_MAX} _SC_NGROUPS_MAX
46 Maximum size of getgrgid_r() and _SC_GETGR_R_SIZE_MAX
47 getgrnam_r() data buffers
48 Maximum size of getpwuid_r() and _SC_GETPW_R_SIZE_MAX
49 getpwnam_r() data buffers
50 {MQ_OPEN_MAX} _SC_MQ_OPEN_MAX
51 {MQ_PRIO_MAX} _SC_MQ_PRIO_MAX
52 {OPEN_MAX} _SC_OPEN_MAX
53 _POSIX_ADVISORY_INFO _SC_ADVISORY_INFO
54 _POSIX_BARRIERS _SC_BARRIERS
55 _POSIX_ASYNCHRONOUS_IO _SC_ASYNCHRONOUS_IO
56 _POSIX_CLOCK_SELECTION _SC_CLOCK_SELECTION
57 _POSIX_CPUTIME _SC_CPUTIME
58 _POSIX_FILE_LOCKING _SC_FILE_LOCKING
59 _POSIX_FSYNC _SC_FSYNC
60 _POSIX_IPV6 _SC_IPV6
61 _POSIX_JOB_CONTROL _SC_JOB_CONTROL
62 _POSIX_MAPPED_FILES _SC_MAPPED_FILES
63 _POSIX_MEMLOCK _SC_MEMLOCK
64 _POSIX_MEMLOCK_RANGE _SC_MEMLOCK_RANGE
65 _POSIX_MEMORY_PROTECTION _SC_MEMORY_PROTECTION
66
67 _POSIX_MESSAGE_PASSING _SC_MESSAGE_PASSING
68 _POSIX_MONOTONIC_CLOCK _SC_MONOTONIC_CLOCK
69 _POSIX_MULTI_PROCESS _SC_MULTI_PROCESS
70 _POSIX_PRIORITIZED_IO _SC_PRIORITIZED_IO
71 _POSIX_PRIORITY_SCHEDULING _SC_PRIORITY_SCHEDULING
72 _POSIX_RAW_SOCKETS _SC_RAW_SOCKETS
73 _POSIX_READER_WRITER_LOCKS _SC_READER_WRITER_LOCKS
74 _POSIX_REALTIME_SIGNALS _SC_REALTIME_SIGNALS
75 _POSIX_REGEXP _SC_REGEXP
76 _POSIX_SAVED_IDS _SC_SAVED_IDS
77 _POSIX_SEMAPHORES _SC_SEMAPHORES
78 _POSIX_SHARED_MEMORY_OBJECTS _SC_SHARED_MEMORY_OBJECTS
79 _POSIX_SHELL _SC_SHELL
80 _POSIX_SPAWN _SC_SPAWN
81 _POSIX_SPIN_LOCKS _SC_SPIN_LOCKS
82 _POSIX_SPORADIC_SERVER _SC_SPORADIC_SERVER
83 _POSIX_SYMLOOP_MAX _SC_SYMLOOP_MAX
84 _POSIX_SYNCHRONIZED_IO _SC_SYNCHRONIZED_IO
85 _POSIX_THREAD_ATTR_STACKADDR _SC_THREAD_ATTR_STACKADDR
86 _POSIX_THREAD_ATTR_STACKSIZE _SC_THREAD_ATTR_STACKSIZE
87 _POSIX_THREAD_CPUTIME _SC_THREAD_CPUTIME
88 _POSIX_THREAD_PRIO_INHERIT _SC_THREAD_PRIO_INHERIT
89 _POSIX_THREAD_PRIO_PROTECT _SC_THREAD_PRIO_PROTECT
90 _POSIX_THREAD_PRIORITY_SCHEDULING _SC_THREAD_PRIORITY_SCHEDULING
91 _POSIX_THREAD_PROCESS_SHARED _SC_THREAD_PROCESS_SHARED
92 _POSIX_THREAD_SAFE_FUNCTIONS _SC_THREAD_SAFE_FUNCTIONS
93 _POSIX_THREAD_SPORADIC_SERVER _SC_THREAD_SPORADIC_SERVER
94 _POSIX_THREADS _SC_THREADS
95 _POSIX_TIMEOUTS _SC_TIMEOUTS
96 _POSIX_TIMERS _SC_TIMERS
97 _POSIX_TRACE _SC_TRACE
98 _POSIX_TRACE_EVENT_FILTER _SC_TRACE_EVENT_FILTER
99 _POSIX_TRACE_INHERIT _SC_TRACE_INHERIT
100 _POSIX_TRACE_LOG _SC_TRACE_LOG
101 _POSIX_TYPED_MEMORY_OBJECTS _SC_TYPED_MEMORY_OBJECTS
102 _POSIX_VERSION _SC_VERSION
103 _POSIX_V6_ILP32_OFF32 _SC_V6_ILP32_OFF32
104 _POSIX_V6_ILP32_OFFBIG _SC_V6_ILP32_OFFBIG
105 _POSIX_V6_LP64_OFF64 _SC_V6_LP64_OFF64
106 _POSIX_V6_LPBIG_OFFBIG _SC_V6_LPBIG_OFFBIG
107 _POSIX2_C_BIND _SC_2_C_BIND
108 _POSIX2_C_DEV _SC_2_C_DEV
109 _POSIX2_C_VERSION _SC_2_C_VERSION
110 _POSIX2_CHAR_TERM _SC_2_CHAR_TERM
111 _POSIX2_FORT_DEV _SC_2_FORT_DEV
112 _POSIX2_FORT_RUN _SC_2_FORT_RUN
113 _POSIX2_LOCALEDEF _SC_2_LOCALEDEF
114 _POSIX2_PBS _SC_2_PBS
115 _POSIX2_PBS_ACCOUNTING _SC_2_PBS_ACCOUNTING
116 _POSIX2_PBS_CHECKPOINT _SC_2_PBS_CHECKPOINT
117 _POSIX2_PBS_LOCATE _SC_2_PBS_LOCATE
118 _POSIX2_PBS_MESSAGE _SC_2_PBS_MESSAGE
119 _POSIX2_PBS_TRACK _SC_2_PBS_TRACK
120 _POSIX2_SW_DEV _SC_2_SW_DEV
121 _POSIX2_UPE _SC_2_UPE
122 _POSIX2_VERSION _SC_2_VERSION
123 _REGEX_VERSION _SC_REGEX_VERSION
124 {PAGE_SIZE} _SC_PAGE_SIZE
125 {PAGESIZE} _SC_PAGESIZE
126 {PTHREAD_DESTRUCTOR_ITERATIONS} _SC_THREAD_DESTRUCTOR_ITERATIONS
127 {PTHREAD_KEYS_MAX} _SC_THREAD_KEYS_MAX
128 {PTHREAD_STACK_MIN} _SC_THREAD_STACK_MIN
129 {PTHREAD_THREADS_MAX} _SC_THREAD_THREADS_MAX
130 {RE_DUP_MAX} _SC_RE_DUP_MAX
131 {RTSIG_MAX} _SC_RTSIG_MAX
132
133 {SEM_NSEMS_MAX} _SC_SEM_NSEMS_MAX
134 {SEM_VALUE_MAX} _SC_SEM_VALUE_MAX
135 {SIGQUEUE_MAX} _SC_SIGQUEUE_MAX
136 {STREAM_MAX} _SC_STREAM_MAX
137 {SYMLOOP_MAX} _SC_SYMLOOP_MAX
138 {TIMER_MAX} _SC_TIMER_MAX
139 {TTY_NAME_MAX} _SC_TTY_NAME_MAX
140 {TZNAME_MAX} _SC_TZNAME_MAX
141 _XBS5_ILP32_OFF32 (LEGACY) _SC_XBS5_ILP32_OFF32 (LEGACY)
142 _XBS5_ILP32_OFFBIG (LEGACY) _SC_XBS5_ILP32_OFFBIG (LEGACY)
143 _XBS5_LP64_OFF64 (LEGACY) _SC_XBS5_LP64_OFF64 (LEGACY)
144 _XBS5_LPBIG_OFFBIG (LEGACY) _SC_XBS5_LPBIG_OFFBIG (LEGACY)
145 _XOPEN_CRYPT _SC_XOPEN_CRYPT
146 _XOPEN_ENH_I18N _SC_XOPEN_ENH_I18N
147 _XOPEN_LEGACY _SC_XOPEN_LEGACY
148 _XOPEN_REALTIME _SC_XOPEN_REALTIME
149 _XOPEN_REALTIME_THREADS _SC_XOPEN_REALTIME_THREADS
150 _XOPEN_SHM _SC_XOPEN_SHM
151 _XOPEN_STREAMS _SC_XOPEN_STREAMS
152 _XOPEN_UNIX _SC_XOPEN_UNIX
153 _XOPEN_VERSION _SC_XOPEN_VERSION
154 _XOPEN_XCU_VERSION _SC_XOPEN_XCU_VERSION
155
157 If name is an invalid value, sysconf() shall return -1 and set errno to
158 indicate the error. If the variable corresponding to name has no limit,
159 sysconf() shall return -1 without changing the value of errno. Note
160 that indefinite limits do not imply infinite limits; see <limits.h>.
161
162 Otherwise, sysconf() shall return the current variable value on the
163 system. The value returned shall not be more restrictive than the cor‐
164 responding value described to the application when it was compiled with
165 the implementation's <limits.h> or <unistd.h>. The value shall not
166 change during the lifetime of the calling process, except that
167 sysconf(_SC_OPEN_MAX) may return different values before and after a
168 call to setrlimit() which changes the RLIMIT_NOFILE soft limit.
169
171 The sysconf() function shall fail if:
172
173 EINVAL The value of the name argument is invalid.
174
175
176 The following sections are informative.
177
179 None.
180
182 As -1 is a permissible return value in a successful situation, an
183 application wishing to check for error situations should set errno to
184 0, then call sysconf(), and, if it returns -1, check to see if errno is
185 non-zero.
186
187 If the value of sysconf(_SC_2_VERSION) is not equal to the value of the
188 _POSIX2_VERSION symbolic constant, the utilities available via system()
189 or popen() might not behave as described in the Shell and Utilities
190 volume of IEEE Std 1003.1-2001. This would mean that the application
191 is not running in an environment that conforms to the Shell and Utili‐
192 ties volume of IEEE Std 1003.1-2001. Some applications might be able to
193 deal with this, others might not. However, the functions defined in
194 this volume of IEEE Std 1003.1-2001 continue to operate as specified,
195 even if sysconf(_SC_2_VERSION) reports that the utilities no longer
196 perform as specified.
197
199 This functionality was added in response to requirements of application
200 developers and of system vendors who deal with many international sys‐
201 tem configurations. It is closely related to pathconf() and fpath‐
202 conf().
203
204 Although a conforming application can run on all systems by never
205 demanding more resources than the minimum values published in this vol‐
206 ume of IEEE Std 1003.1-2001, it is useful for that application to be
207 able to use the actual value for the quantity of a resource available
208 on any given system. To do this, the application makes use of the value
209 of a symbolic constant in <limits.h> or <unistd.h>.
210
211 However, once compiled, the application must still be able to cope if
212 the amount of resource available is increased. To that end, an applica‐
213 tion may need a means of determining the quantity of a resource, or the
214 presence of an option, at execution time.
215
216 Two examples are offered:
217
218 1. Applications may wish to act differently on systems with or without
219 job control. Applications vendors who wish to distribute only a
220 single binary package to all instances of a computer architecture
221 would be forced to assume job control is never available if it were
222 to rely solely on the <unistd.h> value published in this volume of
223 IEEE Std 1003.1-2001.
224
225 2. International applications vendors occasionally require knowledge
226 of the number of clock ticks per second. Without these facilities,
227 they would be required to either distribute their applications par‐
228 tially in source form or to have 50 Hz and 60 Hz versions for the
229 various countries in which they operate.
230
231 It is the knowledge that many applications are actually distributed
232 widely in executable form that leads to this facility. If limited to
233 the most restrictive values in the headers, such applications would
234 have to be prepared to accept the most limited environments offered by
235 the smallest microcomputers. Although this is entirely portable, there
236 was a consensus that they should be able to take advantage of the
237 facilities offered by large systems, without the restrictions associ‐
238 ated with source and object distributions.
239
240 During the discussions of this feature, it was pointed out that it is
241 almost always possible for an application to discern what a value might
242 be at runtime by suitably testing the various functions themselves.
243 And, in any event, it could always be written to adequately deal with
244 error returns from the various functions. In the end, it was felt that
245 this imposed an unreasonable level of complication and sophistication
246 on the application writer.
247
248 This runtime facility is not meant to provide ever-changing values that
249 applications have to check multiple times. The values are seen as
250 changing no more frequently than once per system initialization, such
251 as by a system administrator or operator with an automatic configura‐
252 tion program. This volume of IEEE Std 1003.1-2001 specifies that they
253 shall not change within the lifetime of the process.
254
255 Some values apply to the system overall and others vary at the file
256 system or directory level. The latter are described in pathconf() .
257
258 Note that all values returned must be expressible as integers. String
259 values were considered, but the additional flexibility of this approach
260 was rejected due to its added complexity of implementation and use.
261
262 Some values, such as {PATH_MAX}, are sometimes so large that they must
263 not be used to, say, allocate arrays. The sysconf() function returns a
264 negative value to show that this symbolic constant is not even defined
265 in this case.
266
267 Similar to pathconf(), this permits the implementation not to have a
268 limit. When one resource is infinite, returning an error indicating
269 that some other resource limit has been reached is conforming behavior.
270
272 None.
273
275 confstr() , pathconf() , the Base Definitions volume of
276 IEEE Std 1003.1-2001, <limits.h>, <unistd.h>, the Shell and Utilities
277 volume of IEEE Std 1003.1-2001, getconf
278
280 Portions of this text are reprinted and reproduced in electronic form
281 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
282 -- Portable Operating System Interface (POSIX), The Open Group Base
283 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
284 Electrical and Electronics Engineers, Inc and The Open Group. In the
285 event of any discrepancy between this version and the original IEEE and
286 The Open Group Standard, the original IEEE and The Open Group Standard
287 is the referee document. The original Standard can be obtained online
288 at http://www.opengroup.org/unix/online.html .
289
290
291
292IEEE/The Open Group 2003 SYSCONF(P)