It seems that the POSIX call nftw() doesn't clean up correctly when the flag FTW_CHDIR is used. Example: one directory - without containing subdirectories - containing 4 files. int my_callback() { return 0; } if nftw is called 1000 times as in nftw("." , my_callback, 20, FTW_CHDIR) then I am left with 1000 open file handles afterwards.
Created attachment 4586 [details] testcase source code to reproduce the issue. download the Makefile attachment and type make to build. This should produce two binaries ./ok - which works as expected ./buggy - which shows the described bug when executed the only difference is that the flag FTW_CHDIR is used in ./buggy
Created attachment 4587 [details] Makefile for the testcode simpy type make to build. See upload comment on 'main.cpp' on how to use the testcase
Fixed in git.