On 12/22/2010 03:32 PM, Bruno Haible wrote: > For example, if save_cwd called > currdir_fd = open ("."); > then on a platform that supports fchdir() natively [not gnulib's > emulation], a failure to do fchdir (currdir_fd) is of type (a). > It can only occur if some other part of the program did side > effects on currdir_fd.
Hmm, well, no, the fchdir could also fail if the directory is on a remote file system and the network is down. Or if there is an I/O error (errno == EIO). Or if search permission is absent from the directory, assuming the usual case where the directory was opened with O_RDONLY. There are probably other reasons. One workaround would be to wrap every system call that resolves file names, so that all of these system calls fail if given a relative file name after the fchdir failed. But that sounds pretty drastic.