1SYSCONF(3)                 Linux Programmer's Manual                SYSCONF(3)
2
3
4

NAME

6       sysconf - get configuration information at run time
7

SYNOPSIS

9       #include <unistd.h>
10
11       long sysconf(int name);
12

DESCRIPTION

14       POSIX allows an application to test at compile or run time whether cer‐
15       tain options are supported, or what the value  is  of  certain  config‐
16       urable constants or limits.
17
18       At  compile time this is done by including <unistd.h> and/or <limits.h>
19       and testing the value of certain macros.
20
21       At run time, one can ask for numerical values using the  present  func‐
22       tion  sysconf().   One  can ask for numerical values that may depend on
23       the filesystem in which a file resides  using  fpathconf(3)  and  path‐
24       conf(3).  One can ask for string values using confstr(3).
25
26       The  values obtained from these functions are system configuration con‐
27       stants.  They do not change during the lifetime of a process.
28
29       For options, typically, there is a  constant  _POSIX_FOO  that  may  be
30       defined in <unistd.h>.  If it is undefined, one should ask at run time.
31       If it is defined to -1, then the option is not  supported.   If  it  is
32       defined to 0, then relevant functions and headers exist, but one has to
33       ask at run time what degree of support is available.  If it is  defined
34       to  a  value other than -1 or 0, then the option is supported.  Usually
35       the value (such as 200112L) indicates the year and month of  the  POSIX
36       revision  describing  the  option.   Glibc uses the value 1 to indicate
37       support as long as the POSIX revision has not been published yet.   The
38       sysconf()  argument  will  be  _SC_FOO.   For  a  list  of options, see
39       posixoptions(7).
40
41       For variables or limits, typically, there is  a  constant  _FOO,  maybe
42       defined in <limits.h>, or _POSIX_FOO, maybe defined in <unistd.h>.  The
43       constant will not be defined if the limit is unspecified.  If the  con‐
44       stant  is  defined,  it  gives  a guaranteed value, and a greater value
45       might actually be supported.  If an application wants to take advantage
46       of  values which may change between systems, a call to sysconf() can be
47       made.  The sysconf() argument will be _SC_FOO.
48
49   POSIX.1 variables
50       We give the name of the variable, the name of  the  sysconf()  argument
51       used to inquire about its value, and a short description.
52
53       First, the POSIX.1 compatible values.
54
55       ARG_MAX - _SC_ARG_MAX
56              The  maximum  length  of  the arguments to the exec(3) family of
57              functions.  Must not be less than _POSIX_ARG_MAX (4096).
58
59       CHILD_MAX - _SC_CHILD_MAX
60              The maximum number of simultaneous processes per user ID.   Must
61              not be less than _POSIX_CHILD_MAX (25).
62
63       HOST_NAME_MAX - _SC_HOST_NAME_MAX
64              Maximum length of a hostname, not including the terminating null
65              byte, as returned by gethostname(2).   Must  not  be  less  than
66              _POSIX_HOST_NAME_MAX (255).
67
68       LOGIN_NAME_MAX - _SC_LOGIN_NAME_MAX
69              Maximum  length  of a login name, including the terminating null
70              byte.  Must not be less than _POSIX_LOGIN_NAME_MAX (9).
71
72       NGROUPS_MAX - _SC_NGROUPS_MAX
73              Maximum number of supplementary group IDs.
74
75       clock ticks - _SC_CLK_TCK
76              The number of clock ticks per second.  The  corresponding  vari‐
77              able  is obsolete.  It was of course called CLK_TCK.  (Note: the
78              macro CLOCKS_PER_SEC does not give information:  it  must  equal
79              1000000.)
80
81       OPEN_MAX - _SC_OPEN_MAX
82              The  maximum number of files that a process can have open at any
83              time.  Must not be less than _POSIX_OPEN_MAX (20).
84
85       PAGESIZE - _SC_PAGESIZE
86              Size of a page in bytes.  Must not be less than 1.
87
88       PAGE_SIZE - _SC_PAGE_SIZE
89              A  synonym  for  PAGESIZE/_SC_PAGESIZE.   (Both   PAGESIZE   and
90              PAGE_SIZE are specified in POSIX.)
91
92       RE_DUP_MAX - _SC_RE_DUP_MAX
93              The  number  of  repeated  occurrences  of  a  BRE  permitted by
94              regexec(3)   and   regcomp(3).    Must   not   be   less    than
95              _POSIX2_RE_DUP_MAX (255).
96
97       STREAM_MAX - _SC_STREAM_MAX
98              The  maximum  number  of streams that a process can have open at
99              any time.  If defined, it has the same value as the  standard  C
100              macro FOPEN_MAX.  Must not be less than _POSIX_STREAM_MAX (8).
101
102       SYMLOOP_MAX - _SC_SYMLOOP_MAX
103              The  maximum  number of symbolic links seen in a pathname before
104              resolution returns ELOOP.  Must not  be  less  than  _POSIX_SYM‐
105              LOOP_MAX (8).
106
107       TTY_NAME_MAX - _SC_TTY_NAME_MAX
108              The maximum length of terminal device name, including the termi‐
109              nating null byte.  Must not  be  less  than  _POSIX_TTY_NAME_MAX
110              (9).
111
112       TZNAME_MAX - _SC_TZNAME_MAX
113              The  maximum  number  of  bytes in a timezone name.  Must not be
114              less than _POSIX_TZNAME_MAX (6).
115
116       _POSIX_VERSION - _SC_VERSION
117              indicates the year and month the POSIX.1 standard  was  approved
118              in  the  format  YYYYMML;  the value 199009L indicates the Sept.
119              1990 revision.
120
121   POSIX.2 variables
122       Next, the POSIX.2 values, giving limits for utilities.
123
124       BC_BASE_MAX - _SC_BC_BASE_MAX
125              indicates the maximum obase value accepted by the bc(1) utility.
126
127       BC_DIM_MAX - _SC_BC_DIM_MAX
128              indicates the maximum value of elements permitted in an array by
129              bc(1).
130
131       BC_SCALE_MAX - _SC_BC_SCALE_MAX
132              indicates the maximum scale value allowed by bc(1).
133
134       BC_STRING_MAX - _SC_BC_STRING_MAX
135              indicates the maximum length of a string accepted by bc(1).
136
137       COLL_WEIGHTS_MAX - _SC_COLL_WEIGHTS_MAX
138              indicates the maximum numbers of weights that can be assigned to
139              an entry of the LC_COLLATE order keyword in the  locale  defini‐
140              tion file,
141
142       EXPR_NEST_MAX - _SC_EXPR_NEST_MAX
143              is  the maximum number of expressions which can be nested within
144              parentheses by expr(1).
145
146       LINE_MAX - _SC_LINE_MAX
147              The maximum length of a utility's input line, either from  stan‐
148              dard  input  or from a file.  This includes space for a trailing
149              newline.
150
151       RE_DUP_MAX - _SC_RE_DUP_MAX
152              The maximum number of repeated occurrences of a regular  expres‐
153              sion when the interval notation \{m,n\} is used.
154
155       POSIX2_VERSION - _SC_2_VERSION
156              indicates  the  version of the POSIX.2 standard in the format of
157              YYYYMML.
158
159       POSIX2_C_DEV - _SC_2_C_DEV
160              indicates whether the POSIX.2 C language development  facilities
161              are supported.
162
163       POSIX2_FORT_DEV - _SC_2_FORT_DEV
164              indicates  whether the POSIX.2 FORTRAN development utilities are
165              supported.
166
167       POSIX2_FORT_RUN - _SC_2_FORT_RUN
168              indicates whether the POSIX.2  FORTRAN  run-time  utilities  are
169              supported.
170
171       _POSIX2_LOCALEDEF - _SC_2_LOCALEDEF
172              indicates   whether   the   POSIX.2   creation  of  locates  via
173              localedef(1) is supported.
174
175       POSIX2_SW_DEV - _SC_2_SW_DEV
176              indicates whether the  POSIX.2  software  development  utilities
177              option is supported.
178
179       These values also exist, but may not be standard.
180
181        - _SC_PHYS_PAGES
182              The  number of pages of physical memory.  Note that it is possi‐
183              ble for the product of this value and the value of  _SC_PAGESIZE
184              to overflow.
185
186        - _SC_AVPHYS_PAGES
187              The number of currently available pages of physical memory.
188
189        - _SC_NPROCESSORS_CONF
190              The    number    of    processors    configured.     See    also
191              get_nprocs_conf(3).
192
193        - _SC_NPROCESSORS_ONLN
194              The number of processors currently online (available).  See also
195              get_nprocs_conf(3).
196

RETURN VALUE

198       The return value of sysconf() is one of the following:
199
200       *  On  error,  -1 is returned and errno is set to indicate the cause of
201          the error (for example, EINVAL, indicating that name is invalid).
202
203       *  If name corresponds to a maximum or minimum limit, and that limit is
204          indeterminate, -1 is returned and errno is not changed.  (To distin‐
205          guish an indeterminate limit from an error, set errno to zero before
206          the  call,  and  then  check  whether  errno  is  nonzero when -1 is
207          returned.)
208
209       *  If name corresponds to an option, a positive value  is  returned  if
210          the  option  is  supported,  and -1 is returned if the option is not
211          supported.
212
213       *  Otherwise, the current value of the option  or  limit  is  returned.
214          This value will not be more restrictive than the corresponding value
215          that was described to the application in  <unistd.h>  or  <limits.h>
216          when the application was compiled.
217

ERRORS

219       EINVAL name is invalid.
220

ATTRIBUTES

222       For   an   explanation   of   the  terms  used  in  this  section,  see
223       attributes(7).
224
225       ┌──────────┬───────────────┬─────────────┐
226Interface Attribute     Value       
227       ├──────────┼───────────────┼─────────────┤
228sysconf() │ Thread safety │ MT-Safe env │
229       └──────────┴───────────────┴─────────────┘

CONFORMING TO

231       POSIX.1-2001, POSIX.1-2008.
232

BUGS

234       It is difficult to use ARG_MAX because it is not specified how much  of
235       the  argument  space  for exec(3) is consumed by the user's environment
236       variables.
237
238       Some returned values may be huge; they are not suitable for  allocating
239       memory.
240

SEE ALSO

242       bc(1),  expr(1), getconf(1), locale(1), confstr(3), fpathconf(3), path‐
243       conf(3), posixoptions(7)
244

COLOPHON

246       This page is part of release 5.04 of the Linux  man-pages  project.   A
247       description  of  the project, information about reporting bugs, and the
248       latest    version    of    this    page,    can     be     found     at
249       https://www.kernel.org/doc/man-pages/.
250
251
252
253GNU                               2019-05-09                        SYSCONF(3)
Impressum