chdir - change current directory
Standard C Library (libc, -lc)
#include <unistd.h>
int
chdir(const char *pathname);
The current directory of the current process is set to the directory named by pathname.
chdir (like all system calls) should be atomic. Note that the kernel is not obliged to (and generally cannot) make the chdir call atomic with respect to other threads in the same process accessing the pathname string during the operation.
On success, chdir returns 0. On error, -1 is returned, and errno is set according to the error encountered.
The following error codes should be returned under the conditions given. Other error codes may be returned for other errors not mentioned here.
ENODEV | The device prefix of pathname did not exist. | |
ENOTDIR | A non-final component of pathname was not a directory. | |
ENOTDIR | pathname did not refer to a directory. | |
ENOENT | pathname did not exist. | |
EIO | A hard I/O error occurred. | |
EFAULT | pathname was an invalid pointer. |