Red Hat Bugzilla – Bug 4892
dup2(1, OPEN_MAX) return is not POSIX.1 conformant
Last modified: 2015-01-07 18:37:57 EST
According to POSIX.1 (page 149, 22.214.171.124, lines 70-74), a
call to dup2(1, sysconf(_SC_OPEN_MAX)) should set errno to
EBADF, but instead (incorrectly) sets errno == EMFILE.
This is seen running the PCTS on a stock 6.0 Intel system.
Assigned to dledford
Still exists in 2.2.15pre5.
Last I knew, this is a backwards compatibility issue. In order to keep older
binaries from breaking on new kernels that support thousands of open files in a
single application, the kernels have to *pretend* like OPEN_MAX is 1024, like it
used to be. However, to those applications that know about it, they can call
setrlimit() to increase the number of files allowed. As far as I know, the
result of this situation is that we have some differing error returns and this
is by design. If that's wrong, then I'm sure Alan can correct it ;-)