I am using the POSIX call nftw()
for traversing a directory structure. The directory structure is flat - only 4 files and no subdirectories.
However when I call nftw() a lot of times on this flat directory then I get an error message after a while:
"too many open file handles".
It turned out that this happens when the flag FTW_CHDIR
is used.
Would you agree that it is a bug in the Linux implementation of nftw() ?
UPDATE
A fix is now available in the glibc repositories.
here are some links to the source code I have used for testing:
- main.cpp: http://sourceware.org/bugzilla/attachment.cgi?id=4586&action=view
- Makefile: http://sourceware.org/bugzilla/attachment.cgi?id=4587&action=view
UPDATE
- MacOS-X is also hit by the bug
- Solaris9, Solaris10 and AIX 5.3 do not have the bug