fchdir - change working directory
#include <unistd.h> int fchdir(int fildes);
The fchdir() function has the same effect as chdir() except that the directory that is to be the new current working directory is specified by the file descriptor fildes.
Upon successful completion, fchdir() returns 0. Otherwise, it returns -1 and sets errno to indicate the error. On failure the current working directory remains unchanged.
The fchdir() function will fail if:
- Search permission is denied for the directory referenced by fildes.
- The fildes argument is not an open file descriptor.
- The open file descriptor fildes does not refer to a directory.
The fchdir() may fail if:
- A signal was caught during the execution of fchdir().
- An I/O error occurred while reading from or writing to the file system.