]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/chdir.2
Wrapped long lines, wrapped at sentence boundaries; stripped trailing
[thirdparty/man-pages.git] / man2 / chdir.2
CommitLineData
fea681da
MK
1.\" Hey Emacs! This file is -*- nroff -*- source.
2.\"
3.\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
4.\"
5.\" Permission is granted to make and distribute verbatim copies of this
6.\" manual provided the copyright notice and this permission notice are
7.\" preserved on all copies.
8.\"
9.\" Permission is granted to copy and distribute modified versions of this
10.\" manual under the conditions for verbatim copying, provided that the
11.\" entire resulting derived work is distributed under the terms of a
12.\" permission notice identical to this one.
c13182ef 13.\"
fea681da
MK
14.\" Since the Linux kernel and libraries are constantly changing, this
15.\" manual page may be incorrect or out-of-date. The author(s) assume no
16.\" responsibility for errors or omissions, or for damages resulting from
17.\" the use of the information contained herein. The author(s) may not
18.\" have taken the same level of care in the production of this manual,
19.\" which is licensed free of charge, as they might when working
20.\" professionally.
c13182ef 21.\"
fea681da
MK
22.\" Formatted or processed versions of this manual, if unaccompanied by
23.\" the source, must acknowledge the copyright and authors of this work.
24.\"
25.\" Modified by Michael Haardt <michael@moria.de>
26.\" Modified 1993-07-21 by Rik Faith <faith@cs.unc.edu>
27.\" Modified 1995-04-15 by Michael Chastain <mec@shell.portal.com>:
28.\" Added 'fchdir'. Fixed bugs in error section.
29.\" Modified 1996-10-21 by Eric S. Raymond <esr@thyrsus.com>
30.\" Modified 1997-08-21 by Joseph S. Myers <jsm28@cam.ac.uk>
305a0578 31.\" Modified 2004-06-23 by Michael Kerrisk <mtk-manpages@gmx.net>
fea681da
MK
32.\"
33.TH CHDIR 2 2004-06-23 "Linux 2.6.7" "Linux Programmer's Manual"
34.SH NAME
35chdir, fchdir \- change working directory
36.SH SYNOPSIS
37.B #include <unistd.h>
38.sp
39.BI "int chdir(const char *" path );
40.br
41.BI "int fchdir(int " fd );
42.SH DESCRIPTION
e511ffb6 43.BR chdir ()
75fcdb08 44changes the current working directory to that specified in
fea681da
MK
45.IR path .
46.PP
e511ffb6 47.BR fchdir ()
fea681da 48is identical to
e511ffb6 49.BR chdir ();
fea681da
MK
50the only difference is that the directory is given as an
51open file descriptor.
52.SH "RETURN VALUE"
c13182ef
MK
53On success, zero is returned.
54On error, \-1 is returned, and
fea681da
MK
55.I errno
56is set appropriately.
57.SH ERRORS
c13182ef
MK
58Depending on the file system, other errors can be returned.
59The more
fea681da 60general errors for
e511ffb6 61.BR chdir ()
fea681da
MK
62are listed below:
63.TP
64.B EACCES
c13182ef 65Search permission is denied for one of the directories
75fcdb08 66in the path prefix of
fea681da
MK
67.IR path .
68(See also
69.BR path_resolution (2).)
70.TP
71.B EFAULT
72.I path
73points outside your accessible address space.
74.TP
75.B EIO
76An I/O error occurred.
77.TP
78.B ELOOP
79Too many symbolic links were encountered in resolving
80.IR path .
81.TP
82.B ENAMETOOLONG
83.I path
84is too long.
85.TP
86.B ENOENT
87The file does not exist.
88.TP
89.B ENOMEM
90Insufficient kernel memory was available.
91.TP
92.B ENOTDIR
93A component of
94.I path
95is not a directory.
96.PP
97The general errors for
e511ffb6 98.BR fchdir ()
fea681da
MK
99are listed below:
100.TP
101.B EACCES
102Search permission was denied on the directory open on
103.IR fd .
104.TP
105.B EBADF
106.I fd
107is not a valid file descriptor.
108.SH NOTES
75fcdb08
MK
109A child process created via
110.BR fork (2)
111inherits its parent's current working directory.
112The current working directory is left unchanged by
113.BR execve (2).
114
fea681da 115The prototype for
e511ffb6 116.BR fchdir ()
fea681da 117is only available if
c13182ef 118.B _BSD_SOURCE
ead83042
MK
119is defined, or
120.B _XOPEN_SOURCE
121is defined with the value 500.
fea681da 122.SH "CONFORMING TO"
97c1eac8 123SVr4, 4.4BSD, POSIX.1-2001.
fea681da
MK
124.SH "SEE ALSO"
125.BR chroot (2),
126.BR path_resolution (2),
127.BR getcwd (3)