POSIX defines many such limits to be optional. If a limit FOO is not defined in limits.h
, it means the system may have no such limit or the limit might vary at runtime or dependent upon the pathname it's applied to. In these cases, you use the pathconf
, fpathconf
, or sysconf
functions and the _PC_*
and _SC_*
macros, as in:
path_max = pathconf("/", _PC_PATH_MAX);
or:
page_size = sysconf(_SC_PAGE_SIZE);
Unfortunately GNU (the GNU C library) defines many limits as runtime-variable when they're actually constant on Linux, in some (in my opinion, very misguided) hope that someday the limits will be removed and applications will immediately be able to take advantage of the removal of the limits. However, for application and kernel robustness, it's actually much better to have fixed limits as long as they're sufficiently large (as the Linux limits are).