joerg-krause writes

Not all systems define POSIX.1 value OPEN_MAX. In this case just close all descriptors up to some arbitrary limit - say 256 1.

1 Advanced Programming in the UNIX Environment, Richard Stevens, p. 52.