Advanced Programming in the UNIX® Environment

(lily) #1
ptg10805159

40 UNIX Standardization and Implementations Chapter 2


These minimum values do not change from one system to another.They specify the
most restrictive values for these features. A conforming POSIX.1 implementation must
provide values that are at least this large. This is why they arecalled minimums,
although their names all containMAX.Also, to ensureportability,astrictly conforming
application must not requirealarger value. We describe what each of these constants
refers to as we proceed through the text.

Astrictly conforming POSIX application is different from an application that is merely POSIX
conforming. A POSIX-conforming application uses only interfaces defined in IEEE Standard
1003.1-2008. A strictly conforming POSIX application must meet further restrictions, such as
not relying on any undefined behavior,not using any obsolescent interfaces, and not requiring
values of constants larger than the minimums shown in Figure2.8.

Name Description Minimum acceptable value
ARG_MAX maximum length of arguments toexec _POSIX_ARG_MAX
functions
ATEXIT_MAX maximum number of functions that can be 32
registered with theatexitfunction
CHILD_MAX maximum number of child processes per real _POSIX_CHILD_MAX
user ID
DELAYTIMER_MAX maximum number of timer expiration overruns _POSIX_DELAYTIMER_MAX
HOST_NAME_MAX maximum length of a host name as returned by _POSIX_HOST_NAME_MAX
gethostname
LOGIN_NAME_MAX maximum length of a login name _POSIX_LOGIN_NAME_MAX
OPEN_MAX one morethan the maximum value assigned to _POSIX_OPEN_MAX
anewly created file descriptor
PAGESIZE system memory page size, in bytes 1
RTSIG_MAX maximum number of real-time signals reserved _POSIX_RTSIG_MAX
for application use
SEM_NSEMS_MAX maximum number of semaphores a process can _POSIX_SEM_NSEMS_MAX
use
SEM_VALUE_MAX maximum value of a semaphore _POSIX_SEM_VALUE_MAX
SIGQUEUE_MAX maximum number of signals that can be _POSIX_SIGQUEUE_MAX
queued for a process
STREAM_MAX maximum number of standardI/O streams a _POSIX_STREAM_MAX
process can have open at once
SYMLOOP_MAX number of symbolic links that can be traversed _POSIX_SYMLOOP_MAX
during pathname resolution
TIMER_MAX maximum number of timers per process _POSIX_TIMER_MAX
TTY_NAME_MAX length of a terminal device name, including the _POSIX_TTY_NAME_MAX
terminating null
TZNAME_MAX number of bytes for the name of a time zone _POSIX_TZNAME_MAX

Figure 2.9POSIX.1 runtime invariant values from<limits.h>

Unfortunately,some of these invariant minimum values aretoo small to be of
practical use. For example, most UNIX systems today provide far morethan 20 open
files per process. Also, the minimum limit of 256 for_POSIX_PATH_MAXis too small.
Pathnames can exceed this limit. This means that we can’t use the two constants
_POSIX_OPEN_MAXand_POSIX_PATH_MAXas array sizes at compile time.
Free download pdf