System Limits and Options 215
with the value 8) specifies the SUSv3-required minimum corresponding to the
RTSIG_MAX implementation constant. The third column specifies the constant name
that can be given at run time to sysconf() or pathconf() in order to retrieve the imple-
mentation limit. The constants beginning with _SC_ are for use with sysconf(); those
beginning with _PC_ are for use with pathconf() and fpathconf().
Note the following information supplementary to that shown in Table 11-1:
z The getdtablesize() function is an obsolete alternative for determining the pro-
cess file descriptor limit (OPEN_MAX). This function was specified in SUSv2
(marked LEGACY), but was removed in SUSv3.
z The getpagesize() function is an obsolete alternative for determining the system
page size (_SC_PAGESIZE). This function was specified in SUSv2 (marked LEG-
ACY), but was removed in SUSv3.
z The constant FOPEN_MAX, defined in <stdio.h>, is synonymous with STREAM_MAX.
z NAME_MAX excludes the terminating null byte, while PATH_MAX includes it. This incon-
sistency repairs an earlier inconsistency in the POSIX.1 standard that left it
unclear whether PATH_MAX included the terminating null byte. Defining PATH_MAX to
include the terminator means that applications that allocated just PATH_MAX bytes
for a pathname will still conform to the standard.
Determining limits and options from the shell: getconf
From the shell, we can use the getconf command to obtain the limits and options
implemented by a particular UNIX implementation. The general form of this com-
mand is as follows:
$ getconf variable-name [ pathname ]
The variable-name identifies the limit of interest and is one of the SUSV3 standard
limit names, such as ARG_MAX or NAME_MAX. Where the limit relates to a pathname, we
must specify a pathname as the second argument to the command, as in the second
of the following examples.
$ getconf ARG_MAX
131072
$ getconf NAME_MAX /boot
255
11.2 Retrieving System Limits (and Options) at Run Time
The sysconf() function allows an application to obtain the values of system limits at
run time.
#include <unistd.h>
long sysconf(int name);
Returns value of limit specified by name,
or –1 if limit is indeterminate or an error occurred