Change the working directory
#include <unistd.h> int fchdir(int fd);
- A file descriptor for the directory that you want to become the current working directory.
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The fchdir() function is similar to chdir() , except that you use a file descriptor to specify the directory that you want to become the new current working directory. You can obtain a file descriptor for a directory by calling open() , provided that the file status flags and access modes don't contain O_WRONLY or O_RDWR.
0, or -1 if an error occurred ( errno is set). If the function fails, the current working directory isn't changed.
- Search permission is denied for the directory referenced by fd.
- The fd argument isn't an open file descriptor.
- The open file descriptor fd doesn't refer to a directory.
- A signal was caught during the execution of fchdir().
- An I/O error occurred while reading from or writing to the filesystem.
Last modified: 2013-12-23