CHDIR(3) Library Functions Manual CHDIR(3)

chdirchange working directory

#include <unistd.h>

int chdir(const char *path);

The chdir() function causes the directory named by the pathname pointed to by the path argument to become the current working directory; that is, the starting point for path searches for pathnames not beginning with /.

Upon successful completion, 0 is returned. Otherwise, -1 is returned, the current working directory remains unchanged and errno is set to indicate the error.

The chdir() function will fail if:

Search permission is denied for any component of the pathname.
Too many symbolic links were encountered in resolving path .
The path argument exceeds {PATH_MAX} in length or a pathname component is longer than {NAME_MAX}.
A component of path does not name an existing directory or path is an empty string.
A component of the pathname is not a directory.

The function may fail if:

Pathname resolution of a symbolic link produced an intermediate result whose length exceeds {PATH_MAX}.

None.

None.

None.

getcwd(3) , <unistd.h> .

Derived from Issue 1 of the SVID.

February 1997 posix.fail