Index of Section 2 Manual Pages
| Interix / SUA | fchdir.2 | Interix / SUA |
fchdir(2) fchdir(2)
chdir()
NAME
chdir(), wcs_chdir(), fchdir() - change current working directory
SYNOPSIS
#include
int chdir (const char *path)
int wcs_chdir (const wchar_t *path)
int fchdir (int fildes)
DESCRIPTION
The chdir(2), wcs_chdir(2), and fchdir(2) calls change the current working
directory of a process, that is, the starting point for path searches of
pathnames not beginning with a slash (/).
The chdir(2) and wcs_chdir(2) functions are identical except that the
wcs_chdir(2) function accepts wide characters in the path argument. For
chdir(2) and wcs_chdir(2), the path argument points to the pathname of a
directory. For fchdir(2), the fildes argument is an open file descriptor
specifying a directory.
In order for a directory to become the current directory, a process must
have execute (search) access to the directory.
RETURN VALUES
Upon successfully completing, chdir(2), wcs_chdir(2), and fchdir(2) return
0. Otherwise, they return -1 and errno to indicate the error.
ERRORS
The chdir(2) and wcs_chdir(2) calls will fail and the current working
directory will be unchanged if one or more of the following are true:
[EINVAL]
The pathname contains a character with the high-order bit set.
[ENOTDIR]
A component of the path prefix is not a directory.
[ENAMETOOLONG]
A component of a pathname exceeded {NAME_MAX} characters, or an entire
pathname exceeded {PATH_MAX} characters.
[ENOENT]
The named directory does not exist.
[ELOOP]
Too many symbolic links were encountered in translating the pathname.
[EACCES]
Search permission is denied for any component of the pathname.
The fchdir(2) function will fail for these reasons:
[EACCES]
The process does not have search permission for the directory
indicated by fildes.
[EBADF]
The fildes argument isn't an open file descriptor.
[EINTR]
The call was interrupted by a signal.
[EIO]
There was an I/O error while reading from the filesystem.
[ENOTDIR]
The file descriptor fildes does not point to a directory.
USAGE NOTES
All of these functions are thread safe.
The following functions are async-signal safe: chdir, wcs_chdir. The
following function is not async-signal safe: fchdir.