1CHDIR(2)                   Linux Programmer's Manual                  CHDIR(2)
2
3
4

NAME

6       chdir, fchdir - change working directory
7

SYNOPSIS

9       #include <unistd.h>
10
11       int chdir(const char *path);
12       int fchdir(int fd);
13
14   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
15
16       fchdir(): _BSD_SOURCE || _XOPEN_SOURCE >= 500
17

DESCRIPTION

19       chdir() changes the current working directory of the calling process to
20       the directory specified in path.
21
22       fchdir() is identical to chdir();  the  only  difference  is  that  the
23       directory is given as an open file descriptor.
24

RETURN VALUE

26       On  success,  zero is returned.  On error, -1 is returned, and errno is
27       set appropriately.
28

ERRORS

30       Depending on the file system, other errors can be returned.   The  more
31       general errors for chdir() are listed below:
32
33       EACCES Search  permission  is denied for one of the components of path.
34              (See also path_resolution(7).)
35
36       EFAULT path points outside your accessible address space.
37
38       EIO    An I/O error occurred.
39
40       ELOOP  Too many symbolic links were encountered in resolving path.
41
42       ENAMETOOLONG
43              path is too long.
44
45       ENOENT The file does not exist.
46
47       ENOMEM Insufficient kernel memory was available.
48
49       ENOTDIR
50              A component of path is not a directory.
51
52       The general errors for fchdir() are listed below:
53
54       EACCES Search permission was denied on the directory open on fd.
55
56       EBADF  fd is not a valid file descriptor.
57

CONFORMING TO

59       SVr4, 4.4BSD, POSIX.1-2001.
60

NOTES

62       The current working directory is the starting  point  for  interpreting
63       relative pathnames (those not starting with '/').
64
65       A child process created via fork(2) inherits its parent's current work‐
66       ing directory.  The current working  directory  is  left  unchanged  by
67       execve(2).
68
69       The prototype for fchdir() is only available if _BSD_SOURCE is defined,
70       or _XOPEN_SOURCE is defined with the value 500.
71

SEE ALSO

73       chroot(2), getcwd(3), path_resolution(7)
74

COLOPHON

76       This page is part of release 3.25 of the Linux  man-pages  project.   A
77       description  of  the project, and information about reporting bugs, can
78       be found at http://www.kernel.org/doc/man-pages/.
79
80
81
82Linux                             2007-07-26                          CHDIR(2)
Impressum