Quote:
Originally Posted by
gencon
Thanks Jim and nice hint to use getconf.
The first thing I tried was: getconf _POSIX_OPEN_MAX
and got: 65535
How come in C code when I print the value of _POSIX_OPEN_MAX I get 16 but from bash with getconf I get 65535?
Confused.
Yeah, this is indeed somewhat confusing.
The _POSIX_OPEN_MAX that you print from you program is the limits as defined by the POSIX standard (as of IEEE 1003.1-2008, it's 20). This limit states the minimal number of files that a process can have opened at any time. That is, on a POSIX platform, it is guarantee that any process can have at least up to _POSIX_OPEN_MAX files opened.
Typically, systems like Linux support much more opened file per process that _POSIX_OPEN_MAX.
Now, the value you get with getconf _POSIX_OPEN_MAX is in fact the value obtained with sysconf(_SC_OPEN_MAX). That is, the max. number of files a process can have for the user executing the program (also, in your case what ulimit -n would return).
HTH,
Loïc.