It is safe for multiple processes to, for example, use ftw()
to walk the same directory tree at the same time.
However it is not necessarily safe for one process to be walking the directory tree while another process is updating the same directory tree structure (ie adding, removing or renaming directories). If you have this situation, then you will need to make your CGI processes use an flock()
advisory lock (you could just have a single empty lockfile in the root of the shared directory tree; processes that want to walk the tree have to take a shared lock on that lockfile, and processes that want to alter the tree have to take an exclusive lock on the lockfile).