On 09/18/11 12:11, Jim Meyering wrote: > Since kFreeBSD also lacks /proc/self/fd support, this has the > drawback of making getcwd non-thread-safe, and making it possible > that getcwd will exit under some unusual conditions. But neither > of those matter to coreutils,
I doubt whether they matter to anyone else. POSIX says getcwd must be thread-safe, but I expect that this is because the POSIX folks haven't thought things through: surely common getcwd implementations mess up if some other thread is merrily issuing chdir calls while getcwd is running. The "unusual conditions" are the usual business with file descriptor drought, or if the current directory is searchable but unreadable, right? For that, I expect the emulation would be OK as well. Maybe we could define HAVE_OPENAT_SUPPORT to be one if either openat exists, or the openat module is in use? That might be a more-conservative fix than simply assuming HAVE_OPENAT.