| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 2: System Calls Oracle Solaris 11 Information Library |
- change working directory
#include <unistd.h>intchdir(const char *path);
intfchdir(intfildes);
Thechdir() andfchdir() functions cause a directory pointed to bypathorfildes to become the current working directory. The starting pointfor path searches for path names not beginning with/ (slash). Thepath argument points to the path name of a directory. Thefildesargument is an open file descriptor of a directory.
For a directory to become the current directory, a process must haveexecute (search) access to the directory.
Upon successful completion,0 is returned. Otherwise,-1 is returned, the currentworking directory is unchanged, anderrno is set to indicate the error.
Thechdir() function will fail if:
Search permission is denied for any component of the path name.
Thepath argument points to an illegal address.
A signal was caught during the execution of thechdir() function.
An I/O error occurred while reading from or writing to the file system.
Too many symbolic links were encountered in translatingpath.
The length of thepath argument exceedsPATH_MAX, or the length of apath component exceedsNAME_MAX while_POSIX_NO_TRUNC is in effect.
Either a component of the path prefix or the directory named bypath does not exist or is a null pathname.
Thepath argument points to a remote machine and the link to that machine is no longer active.
A component of the path name is not a directory.
Thefchdir() function will fail if:
Search permission is denied forfildes.
Thefildes argument is not an open file descriptor.
A signal was caught during the execution of thefchdir() function.
An I/O error occurred while reading from or writing to the file system.
Thefildes argument points to a remote machine and the link to that machine is no longer active.
The open file descriptorfildes does not refer to a directory.
Seeattributes(5) for descriptions of the following attributes:
|
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |