CHDIR(2) | System Calls | CHDIR(2) |
chdir, fchdir - change working directory
#include <unistd.h> int chdir(const char *path);
int fchdir(int fildes);
The chdir() and fchdir() functions cause a directory pointed to by path or fildes to become the current working directory. The starting point for path searches for path names not beginning with / (slash). The path argument points to the path name of a directory. The fildes argument is an open file descriptor of a directory.
For a directory to become the current directory, a process must have execute (search) access to the directory.
Upon successful completion, 0 is returned. Otherwise, −1 is returned, the current working directory is unchanged, and errno is set to indicate the error.
The chdir() function will fail if:
EACCES
EFAULT
EINTR
EIO
ELOOP
ENAMETOOLONG
ENOENT
ENOLINK
ENOTDIR
The fchdir() function will fail if:
EACCES
EBADF
EINTR
EIO
ENOLINK
ENOTDIR
See attributes(7) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
Interface Stability | Standard |
MT-Level | Async-Signal-Safe |
December 28, 1996 | OmniOS |