The POSIX.1 and POSIX.2 standards specify a number of parameters that describe capacity limitations of the system. These limits can be fixed constants for a given operating system, or they can vary from machine to machine. For example, some limit values may be configurable by the system administrator, either at run time or by rebuilding the kernel, and this should not require recompiling application programs.
Each of the following limit parameters has a macro that is defined in
limits.h only if the system has a fixed, uniform limit for the
parameter in question. If the system allows different file systems or
files to have different limits, then the macro is undefined; use
sysconf
to find out the limit that applies at a particular time
on a particular machine. See Using sysconf
.
Each of these parameters also has another macro, with a name starting with ‘_POSIX’, which gives the lowest value that the limit is allowed to have on any POSIX system. See Minimum Values for General Capacity Limits.
int
ARG_MAX ¶If defined, the unvarying maximum combined length of the argv and
environ arguments that can be passed to the exec
functions.
int
CHILD_MAX ¶If defined, the unvarying maximum number of processes that can exist
with the same real user ID at any one time. In BSD and GNU, this is
controlled by the RLIMIT_NPROC
resource limit; see Limiting Resource Usage.
int
OPEN_MAX ¶If defined, the unvarying maximum number of files that a single process
can have open simultaneously. In BSD and GNU, this is controlled
by the RLIMIT_NOFILE
resource limit; see Limiting Resource Usage.
int
STREAM_MAX ¶If defined, the unvarying maximum number of streams that a single process can have open simultaneously. See Opening Streams.
int
TZNAME_MAX ¶If defined, the unvarying maximum length of a time zone abbreviation. See Functions and Variables for Time Zones.
These limit macros are always defined in limits.h.
int
NGROUPS_MAX ¶The maximum number of supplementary group IDs that one process can have.
The value of this macro is actually a lower bound for the maximum. That
is, you can count on being able to have that many supplementary group
IDs, but a particular machine might let you have even more. You can use
sysconf
to see whether a particular machine will let you have
more (see Using sysconf
).
ssize_t
SSIZE_MAX ¶The largest value that can fit in an object of type ssize_t
.
Effectively, this is the limit on the number of bytes that can be read
or written in a single operation.
This macro is defined in all POSIX systems because this limit is never configurable.
int
RE_DUP_MAX ¶The largest number of repetitions you are guaranteed is allowed in the construct ‘\{min,max\}’ in a regular expression.
The value of this macro is actually a lower bound for the maximum. That
is, you can count on being able to have that many repetitions, but a
particular machine might let you have even more. You can use
sysconf
to see whether a particular machine will let you have
more (see Using sysconf
). And even the value that sysconf
tells
you is just a lower bound—larger values might work.
This macro is defined in all POSIX.2 systems, because POSIX.2 says it should always be defined even if there is no specific imposed limit.