For what it's worth, in 2007 the 4th edition of Linux Programming Startup was published; parts of it may be a bit dated. (This is not criticism of a book that I have not read.)
OPEN_MAX seems to be deprecated, at least on Linux systems. The reason is that the maximum number of files that can be opened at the same time is not fixed, so a macro that expands to an integer literal is not a good way to get this information.
There will be another macro FOPEN_MAX , which should be similar; I cannot think of why OPEN_MAX and FOPEN_MAX , if both are defined, should have different meanings. But FOPEN_MAX defined by the C language standard, so the system does not have the ability not to define it. The C standard says FOPEN_MAX
expands to an integer constant expression, which is the minimum number of files that implementation guarantees can be opened at the same time
(If the word "minimum" is confusing, this ensures that the program can open at least several files at once.)
If you want to get the maximum number of files that can be opened, look at the sysconf() function; on my system, sysconf(_SC_OPEN_MAX) returns 1024. (The sysconf() man page refers to the OPEN_MAX character. This is not an account, but a value recognized by sysconf() . And it is not defined on my system.)
I searched for OPEN_MAX (word matching, excluding FOPEN_MAX ) on my Ubuntu system, and found the following (these are obviously just short excerpts):
/usr/include/X11/Xos.h :
# ifdef __GNU__ # define PATH_MAX 4096 # define MAXPATHLEN 4096 # define OPEN_MAX 256 # endif
/usr/include/i386-linux-gnu/bits/local_lim.h :
#ifndef NR_OPEN # define __undef_NR_OPEN #endif #ifndef LINK_MAX # define __undef_LINK_MAX #endif #ifndef OPEN_MAX # define __undef_OPEN_MAX #endif #ifndef ARG_MAX # define __undef_ARG_MAX #endif
/usr/include/i386-linux-gnu/bits/xopen_lim.h :
/* We do not provide fixed values for ARG_MAX Maximum length of argument to the `exec' function including environment data. ATEXIT_MAX Maximum number of functions that may be registered with `atexit'. CHILD_MAX Maximum number of simultaneous processes per real user ID. OPEN_MAX Maximum number of files that one process can have open at anyone time. PAGESIZE PAGE_SIZE Size of bytes of a page. PASS_MAX Maximum number of significant bytes in a password. We only provide a fixed limit for IOV_MAX Maximum number of `iovec' structures that one process has available for use with `readv' or writev'. if this is indeed fixed by the underlying system. */