1SYSCONF(3P)                POSIX Programmer's Manual               SYSCONF(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       sysconf — get configurable system variables
14

SYNOPSIS

16       #include <unistd.h>
17
18       long sysconf(int name);
19

DESCRIPTION

21       The sysconf() function provides a method for the application to  deter‐
22       mine  the current value of a configurable system limit or option (vari‐
23       able).  The implementation shall support all of the variables listed in
24       the following table and may support others.
25
26       The  name  argument  represents  the system variable to be queried. The
27       following table lists the minimal set of system  variables  from  <lim‐
28       its.h>  or  <unistd.h>  that can be returned by sysconf(), and the sym‐
29       bolic constants defined in <unistd.h> that are the corresponding values
30       used for name.
31
32        ┌─────────────────────────────────┬──────────────────────────────────┐
33Variable             Value of Name           
34        ├─────────────────────────────────┼──────────────────────────────────┤
35        │{AIO_LISTIO_MAX}                 │_SC_AIO_LISTIO_MAX                │
36        │{AIO_MAX}                        │_SC_AIO_MAX                       │
37        │{AIO_PRIO_DELTA_MAX}             │_SC_AIO_PRIO_DELTA_MAX            │
38        │{ARG_MAX}                        │_SC_ARG_MAX                       │
39        │{ATEXIT_MAX}                     │_SC_ATEXIT_MAX                    │
40        │{BC_BASE_MAX}                    │_SC_BC_BASE_MAX                   │
41        │{BC_DIM_MAX}                     │_SC_BC_DIM_MAX                    │
42        │{BC_SCALE_MAX}                   │_SC_BC_SCALE_MAX                  │
43        │{BC_STRING_MAX}                  │_SC_BC_STRING_MAX                 │
44        │{CHILD_MAX}                      │_SC_CHILD_MAX                     │
45        │Clock ticks/second               │_SC_CLK_TCK                       │
46        │{COLL_WEIGHTS_MAX}               │_SC_COLL_WEIGHTS_MAX              │
47        │{DELAYTIMER_MAX}                 │_SC_DELAYTIMER_MAX                │
48        │{EXPR_NEST_MAX}                  │_SC_EXPR_NEST_MAX                 │
49        │{HOST_NAME_MAX}                  │_SC_HOST_NAME_MAX                 │
50        │{IOV_MAX}                        │_SC_IOV_MAX                       │
51        │{LINE_MAX}                       │_SC_LINE_MAX                      │
52        │{LOGIN_NAME_MAX}                 │_SC_LOGIN_NAME_MAX                │
53        │{NGROUPS_MAX}                    │_SC_NGROUPS_MAX                   │
54        │Initial size of getgrgid_r() and │_SC_GETGR_R_SIZE_MAX              │
55getgrnam_r() data buffers        │                                  │
56        │Initial size of getpwuid_r() and │_SC_GETPW_R_SIZE_MAX              │
57getpwnam_r() data buffers        │                                  │
58        │{MQ_OPEN_MAX}                    │_SC_MQ_OPEN_MAX                   │
59        │{MQ_PRIO_MAX}                    │_SC_MQ_PRIO_MAX                   │
60        │{OPEN_MAX}                       │_SC_OPEN_MAX                      │
61        │_POSIX_ADVISORY_INFO             │_SC_ADVISORY_INFO                 │
62        │_POSIX_BARRIERS                  │_SC_BARRIERS                      │
63        │_POSIX_ASYNCHRONOUS_IO           │_SC_ASYNCHRONOUS_IO               │
64        │_POSIX_CLOCK_SELECTION           │_SC_CLOCK_SELECTION               │
65        │_POSIX_CPUTIME                   │_SC_CPUTIME                       │
66        │_POSIX_FSYNC                     │_SC_FSYNC                         │
67        │_POSIX_IPV6                      │_SC_IPV6                          │
68        │_POSIX_JOB_CONTROL               │_SC_JOB_CONTROL                   │
69        │_POSIX_MAPPED_FILES              │_SC_MAPPED_FILES                  │
70        │_POSIX_MEMLOCK                   │_SC_MEMLOCK                       │
71        │_POSIX_MEMLOCK_RANGE             │_SC_MEMLOCK_RANGE                 │
72        │_POSIX_MEMORY_PROTECTION         │_SC_MEMORY_PROTECTION             │
73        │_POSIX_MESSAGE_PASSING           │_SC_MESSAGE_PASSING               │
74        │_POSIX_MONOTONIC_CLOCK           │_SC_MONOTONIC_CLOCK               │
75        │_POSIX_PRIORITIZED_IO            │_SC_PRIORITIZED_IO                │
76        │_POSIX_PRIORITY_SCHEDULING       │_SC_PRIORITY_SCHEDULING           │
77        │_POSIX_RAW_SOCKETS               │_SC_RAW_SOCKETS                   │
78        │_POSIX_READER_WRITER_LOCKS       │_SC_READER_WRITER_LOCKS           │
79        │_POSIX_REALTIME_SIGNALS          │_SC_REALTIME_SIGNALS              │
80        │_POSIX_REGEXP                    │_SC_REGEXP                        │
81        │_POSIX_SAVED_IDS                 │_SC_SAVED_IDS                     │
82        │_POSIX_SEMAPHORES                │_SC_SEMAPHORES                    │
83        │_POSIX_SHARED_MEMORY_OBJECTS     │_SC_SHARED_MEMORY_OBJECTS         │
84        │_POSIX_SHELL                     │_SC_SHELL                         │
85        │_POSIX_SPAWN                     │_SC_SPAWN                         │
86        │_POSIX_SPIN_LOCKS                │_SC_SPIN_LOCKS                    │
87        │_POSIX_SPORADIC_SERVER           │_SC_SPORADIC_SERVER               │
88        │_POSIX_SS_REPL_MAX               │_SC_SS_REPL_MAX                   │
89        │_POSIX_SYNCHRONIZED_IO           │_SC_SYNCHRONIZED_IO               │
90        │_POSIX_THREAD_ATTR_STACKADDR     │_SC_THREAD_ATTR_STACKADDR         │
91        │_POSIX_THREAD_ATTR_STACKSIZE     │_SC_THREAD_ATTR_STACKSIZE         │
92        │_POSIX_THREAD_CPUTIME            │_SC_THREAD_CPUTIME                │
93        │_POSIX_THREAD_PRIO_INHERIT       │_SC_THREAD_PRIO_INHERIT           │
94        │_POSIX_THREAD_PRIO_PROTECT       │_SC_THREAD_PRIO_PROTECT           │
95        │_POSIX_THREAD_PRIORITY_SCHEDULING│_SC_THREAD_PRIORITY_SCHEDULING    │
96        │_POSIX_THREAD_PROCESS_SHARED     │_SC_THREAD_PROCESS_SHARED         │
97        │_POSIX_THREAD_ROBUST_PRIO_INHERIT│_SC_THREAD_ROBUST_PRIO_INHERIT    │
98        │_POSIX_THREAD_ROBUST_PRIO_PROTECT│_SC_THREAD_ROBUST_PRIO_PROTECT    │
99        │_POSIX_THREAD_SAFE_FUNCTIONS     │_SC_THREAD_SAFE_FUNCTIONS         │
100        │_POSIX_THREAD_SPORADIC_SERVER    │_SC_THREAD_SPORADIC_SERVER        │
101        │_POSIX_THREADS                   │_SC_THREADS                       │
102        │_POSIX_TIMEOUTS                  │_SC_TIMEOUTS                      │
103        │_POSIX_TIMERS                    │_SC_TIMERS                        │
104        │_POSIX_TRACE                     │_SC_TRACE                         │
105        │_POSIX_TRACE_EVENT_FILTER        │_SC_TRACE_EVENT_FILTER            │
106        │_POSIX_TRACE_EVENT_NAME_MAX      │_SC_TRACE_EVENT_NAME_MAX          │
107        │_POSIX_TRACE_INHERIT             │_SC_TRACE_INHERIT                 │
108        │_POSIX_TRACE_LOG                 │_SC_TRACE_LOG                     │
109        │_POSIX_TRACE_NAME_MAX            │_SC_TRACE_NAME_MAX                │
110        │_POSIX_TRACE_SYS_MAX             │_SC_TRACE_SYS_MAX                 │
111        │_POSIX_TRACE_USER_EVENT_MAX      │_SC_TRACE_USER_EVENT_MAX          │
112        │_POSIX_TYPED_MEMORY_OBJECTS      │_SC_TYPED_MEMORY_OBJECTS          │
113        │_POSIX_VERSION                   │_SC_VERSION                       │
114        │_POSIX_V7_ILP32_OFF32            │_SC_V7_ILP32_OFF32                │
115        │_POSIX_V7_ILP32_OFFBIG           │_SC_V7_ILP32_OFFBIG               │
116        │_POSIX_V7_LP64_OFF64             │_SC_V7_LP64_OFF64                 │
117        │_POSIX_V7_LPBIG_OFFBIG           │_SC_V7_LPBIG_OFFBIG               │
118        └─────────────────────────────────┴──────────────────────────────────┘
119         ┌────────────────────────────────┬─────────────────────────────────┐
120Variable            Value of Name           
121         ├────────────────────────────────┼─────────────────────────────────┤
122         │_POSIX_V6_ILP32_OFF32           │_SC_V6_ILP32_OFF32               │
123         │_POSIX_V6_ILP32_OFFBIG          │_SC_V6_ILP32_OFFBIG              │
124         │_POSIX_V6_LP64_OFF64            │_SC_V6_LP64_OFF64                │
125         │_POSIX_V6_LPBIG_OFFBIG          │_SC_V6_LPBIG_OFFBIG              │
126         │_POSIX2_C_BIND                  │_SC_2_C_BIND                     │
127         │_POSIX2_C_DEV                   │_SC_2_C_DEV                      │
128         │_POSIX2_CHAR_TERM               │_SC_2_CHAR_TERM                  │
129         │_POSIX2_FORT_DEV                │_SC_2_FORT_DEV                   │
130         │_POSIX2_FORT_RUN                │_SC_2_FORT_RUN                   │
131         │_POSIX2_LOCALEDEF               │_SC_2_LOCALEDEF                  │
132         │_POSIX2_PBS                     │_SC_2_PBS                        │
133         │_POSIX2_PBS_ACCOUNTING          │_SC_2_PBS_ACCOUNTING             │
134         │_POSIX2_PBS_CHECKPOINT          │_SC_2_PBS_CHECKPOINT             │
135         │_POSIX2_PBS_LOCATE              │_SC_2_PBS_LOCATE                 │
136         │_POSIX2_PBS_MESSAGE             │_SC_2_PBS_MESSAGE                │
137         │_POSIX2_PBS_TRACK               │_SC_2_PBS_TRACK                  │
138         │_POSIX2_SW_DEV                  │_SC_2_SW_DEV                     │
139         │_POSIX2_UPE                     │_SC_2_UPE                        │
140         │_POSIX2_VERSION                 │_SC_2_VERSION                    │
141         │{PAGE_SIZE}                     │_SC_PAGE_SIZE                    │
142         │{PAGESIZE}                      │_SC_PAGESIZE                     │
143         │{PTHREAD_DESTRUCTOR_ITERATIONS} │_SC_THREAD_DESTRUCTOR_ITERATIONS │
144         │{PTHREAD_KEYS_MAX}              │_SC_THREAD_KEYS_MAX              │
145         │{PTHREAD_STACK_MIN}             │_SC_THREAD_STACK_MIN             │
146         │{PTHREAD_THREADS_MAX}           │_SC_THREAD_THREADS_MAX           │
147         │{RE_DUP_MAX}                    │_SC_RE_DUP_MAX                   │
148         │{RTSIG_MAX}                     │_SC_RTSIG_MAX                    │
149         │{SEM_NSEMS_MAX}                 │_SC_SEM_NSEMS_MAX                │
150         │{SEM_VALUE_MAX}                 │_SC_SEM_VALUE_MAX                │
151         │{SIGQUEUE_MAX}                  │_SC_SIGQUEUE_MAX                 │
152         │{STREAM_MAX}                    │_SC_STREAM_MAX                   │
153         │{SYMLOOP_MAX}                   │_SC_SYMLOOP_MAX                  │
154         │{TIMER_MAX}                     │_SC_TIMER_MAX                    │
155         │{TTY_NAME_MAX}                  │_SC_TTY_NAME_MAX                 │
156         │{TZNAME_MAX}                    │_SC_TZNAME_MAX                   │
157         │_XOPEN_CRYPT                    │_SC_XOPEN_CRYPT                  │
158         │_XOPEN_ENH_I18N                 │_SC_XOPEN_ENH_I18N               │
159         │_XOPEN_REALTIME                 │_SC_XOPEN_REALTIME               │
160         │_XOPEN_REALTIME_THREADS         │_SC_XOPEN_REALTIME_THREADS       │
161         │_XOPEN_SHM                      │_SC_XOPEN_SHM                    │
162         │_XOPEN_STREAMS                  │_SC_XOPEN_STREAMS                │
163         │_XOPEN_UNIX                     │_SC_XOPEN_UNIX                   │
164         │_XOPEN_UUCP                     │_SC_XOPEN_UUCP                   │
165         │_XOPEN_VERSION                  │_SC_XOPEN_VERSION                │
166         └────────────────────────────────┴─────────────────────────────────┘

RETURN VALUE

168       If name is an invalid value, sysconf() shall return −1 and set errno to
169       indicate the error. If the variable corresponding to name is  described
170       in  <limits.h>  as  a  maximum or minimum value and the variable has no
171       limit, sysconf() shall return −1 without changing the value  of  errno.
172       Note  that  indefinite  limits  do not imply infinite limits; see <lim‐
173       its.h>.
174
175       Otherwise, sysconf() shall return the current  variable  value  on  the
176       system.  The value returned shall not be more restrictive than the cor‐
177       responding value described to the application when it was compiled with
178       the  implementation's  <limits.h>  or  <unistd.h>.  The value shall not
179       change  during  the  lifetime  of  the  calling  process,  except  that
180       sysconf(_SC_OPEN_MAX)  may  return  different values before and after a
181       call to setrlimit() which changes the RLIMIT_NOFILE soft limit.
182
183       If the variable corresponding to name is dependent  on  an  unsupported
184       option, the results are unspecified.
185

ERRORS

187       The sysconf() function shall fail if:
188
189       EINVAL The value of the name argument is invalid.
190
191       The following sections are informative.
192

EXAMPLES

194       None.
195

APPLICATION USAGE

197       As  −1  is  a  permissible  return  value in a successful situation, an
198       application wishing to check for error situations should set  errno  to
199       0, then call sysconf(), and, if it returns −1, check to see if errno is
200       non-zero.
201
202       Application  developers  should  check  whether  an  option,  such   as
203       _POSIX_TRACE,  is  supported  prior  to  obtaining and using values for
204       related variables, such as _POSIX_TRACE_NAME_MAX.
205

RATIONALE

207       This functionality was added in response to requirements of application
208       developers  and of system vendors who deal with many international sys‐
209       tem configurations. It is closely  related  to  pathconf()  and  fpath‐
210       conf().
211
212       Although  a  conforming  application  can  run  on all systems by never
213       demanding more resources than the minimum values published in this vol‐
214       ume  of  POSIX.1‐2008,  it is useful for that application to be able to
215       use the actual value for the quantity of a resource  available  on  any
216       given  system.  To do this, the application makes use of the value of a
217       symbolic constant in <limits.h> or <unistd.h>.
218
219       However, once compiled, the application must still be able to  cope  if
220       the amount of resource available is increased. To that end, an applica‐
221       tion may need a means of determining the quantity of a resource, or the
222       presence of an option, at execution time.
223
224       Two examples are offered:
225
226        1. Applications may wish to act differently on systems with or without
227           job control.  Applications vendors who wish to  distribute  only  a
228           single  binary  package to all instances of a computer architecture
229           would be forced to assume job control is never available if it were
230           to  rely solely on the <unistd.h> value published in this volume of
231           POSIX.1‐2008.
232
233        2. International applications vendors occasionally  require  knowledge
234           of the number of clock ticks per second.  Without these facilities,
235           they would be required to either distribute their applications par‐
236           tially  in  source form or to have 50 Hz and 60 Hz versions for the
237           various countries in which they operate.
238
239       It is the knowledge that many  applications  are  actually  distributed
240       widely  in  executable  form that leads to this facility. If limited to
241       the most restrictive values in the  headers,  such  applications  would
242       have  to be prepared to accept the most limited environments offered by
243       the smallest microcomputers. Although this is entirely portable,  there
244       was  a  consensus  that  they  should  be able to take advantage of the
245       facilities offered by large systems, without the  restrictions  associ‐
246       ated with source and object distributions.
247
248       During  the  discussions of this feature, it was pointed out that it is
249       almost always possible for an application to discern what a value might
250       be  at  runtime  by  suitably testing the various functions themselves.
251       And, in any event, it could always be written to adequately  deal  with
252       error  returns from the various functions. In the end, it was felt that
253       this imposed an unreasonable level of complication  and  sophistication
254       on the application developer.
255
256       This runtime facility is not meant to provide ever-changing values that
257       applications have to check multiple  times.  The  values  are  seen  as
258       changing  no  more frequently than once per system initialization, such
259       as by a system administrator or operator with an  automatic  configura‐
260       tion program. This volume of POSIX.1‐2008 specifies that they shall not
261       change within the lifetime of the process.
262
263       Some values apply to the system overall and others  vary  at  the  file
264       system or directory level. The latter are described in fpathconf().
265
266       Note  that  all values returned must be expressible as integers. String
267       values were considered, but the additional flexibility of this approach
268       was rejected due to its added complexity of implementation and use.
269
270       Some  values, such as {PATH_MAX}, are sometimes so large that they must
271       not be used to, say, allocate arrays. The sysconf() function returns  a
272       negative  value to show that this symbolic constant is not even defined
273       in this case.
274
275       Similar to pathconf(), this permits the implementation not  to  have  a
276       limit.  When  one  resource  is infinite, returning an error indicating
277       that some other resource limit has been reached is conforming behavior.
278

FUTURE DIRECTIONS

280       None.
281

SEE ALSO

283       confstr(), fpathconf()
284
285       The Base Definitions volume of POSIX.1‐2008, <limits.h>, <unistd.h>
286
287       The Shell and Utilities volume of POSIX.1‐2008, getconf
288
290       Portions of this text are reprinted and reproduced in  electronic  form
291       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
292       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
293       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
294       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
295       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
296       event of any discrepancy between this version and the original IEEE and
297       The  Open Group Standard, the original IEEE and The Open Group Standard
298       is the referee document. The original Standard can be  obtained  online
299       at http://www.unix.org/online.html .
300
301       Any  typographical  or  formatting  errors that appear in this page are
302       most likely to have been introduced during the conversion of the source
303       files  to  man page format. To report such errors, see https://www.ker
304       nel.org/doc/man-pages/reporting_bugs.html .
305
306
307
308IEEE/The Open Group                  2013                          SYSCONF(3P)
Impressum