1CHDIR(3P)                  POSIX Programmer's Manual                 CHDIR(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       chdir - change working directory
13

SYNOPSIS

15       #include <unistd.h>
16
17       int chdir(const char *path);
18
19

DESCRIPTION

21       The chdir() function shall cause the directory named  by  the  pathname
22       pointed  to  by  the path argument to become the current working direcā€
23       tory; that is, the starting point for path searches for  pathnames  not
24       beginning with '/' .
25

RETURN VALUE

27       Upon successful completion, 0 shall be returned. Otherwise, -1 shall be
28       returned, the current working directory  shall  remain  unchanged,  and
29       errno shall be set to indicate the error.
30

ERRORS

32       The chdir() function shall fail if:
33
34       EACCES Search permission is denied for any component of the pathname.
35
36       ELOOP  A loop exists in symbolic links encountered during resolution of
37              the path argument.
38
39       ENAMETOOLONG
40              The length of the path argument exceeds {PATH_MAX} or a pathname
41              component is longer than {NAME_MAX}.
42
43       ENOENT A  component of path does not name an existing directory or path
44              is an empty string.
45
46       ENOTDIR
47              A component of the pathname is not a directory.
48
49
50       The chdir() function may fail if:
51
52       ELOOP  More than {SYMLOOP_MAX} symbolic links were  encountered  during
53              resolution of the path argument.
54
55       ENAMETOOLONG
56              As a result of encountering a symbolic link in resolution of the
57              path argument, the length of  the  substituted  pathname  string
58              exceeded {PATH_MAX}.
59
60
61       The following sections are informative.
62

EXAMPLES

64   Changing the Current Working Directory
65       The  following  example  makes the value pointed to by directory, /tmp,
66       the current working directory.
67
68
69              #include <unistd.h>
70              ...
71              char *directory = "/tmp";
72              int ret;
73
74
75              ret = chdir (directory);
76

APPLICATION USAGE

78       None.
79

RATIONALE

81       The chdir() function only affects the working directory of the  current
82       process.
83

FUTURE DIRECTIONS

85       None.
86

SEE ALSO

88       getcwd(),   the   Base   Definitions  volume  of  IEEE Std 1003.1-2001,
89       <unistd.h>
90
92       Portions of this text are reprinted and reproduced in  electronic  form
93       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
94       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
95       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
96       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
97       event of any discrepancy between this version and the original IEEE and
98       The Open Group Standard, the original IEEE and The Open Group  Standard
99       is  the  referee document. The original Standard can be obtained online
100       at http://www.opengroup.org/unix/online.html .
101
102
103
104IEEE/The Open Group                  2003                            CHDIR(3P)
Impressum