]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/chdir.2
Change use of quote characters to get better UTF-8 rendering.
[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>
c11b1abf 31.\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
fea681da 32.\"
cc4615cc 33.TH CHDIR 2 2007-07-26 "Linux" "Linux Programmer's Manual"
fea681da
MK
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 );
cc4615cc
MK
42.sp
43.in -4n
44Feature Test Macro Requirements for glibc (see
45.BR feature_test_macros (7)):
46.in
47.sp
48.BR fchdir ():
49_BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500
fea681da 50.SH DESCRIPTION
e511ffb6 51.BR chdir ()
551d5b7a 52changes the current working directory of the calling process to the
ee62201f 53directory specified in
fea681da
MK
54.IR path .
55.PP
e511ffb6 56.BR fchdir ()
fea681da 57is identical to
e511ffb6 58.BR chdir ();
fea681da
MK
59the only difference is that the directory is given as an
60open file descriptor.
61.SH "RETURN VALUE"
c13182ef
MK
62On success, zero is returned.
63On error, \-1 is returned, and
fea681da
MK
64.I errno
65is set appropriately.
66.SH ERRORS
c13182ef
MK
67Depending on the file system, other errors can be returned.
68The more
fea681da 69general errors for
e511ffb6 70.BR chdir ()
fea681da
MK
71are listed below:
72.TP
73.B EACCES
ee62201f 74Search permission is denied for one of the components of
fea681da
MK
75.IR path .
76(See also
ad7cc990 77.BR path_resolution (7).)
fea681da
MK
78.TP
79.B EFAULT
80.I path
81points outside your accessible address space.
82.TP
83.B EIO
84An I/O error occurred.
85.TP
86.B ELOOP
87Too many symbolic links were encountered in resolving
88.IR path .
89.TP
90.B ENAMETOOLONG
91.I path
92is too long.
93.TP
94.B ENOENT
95The file does not exist.
96.TP
97.B ENOMEM
98Insufficient kernel memory was available.
99.TP
100.B ENOTDIR
101A component of
102.I path
103is not a directory.
104.PP
105The general errors for
e511ffb6 106.BR fchdir ()
fea681da
MK
107are listed below:
108.TP
109.B EACCES
110Search permission was denied on the directory open on
111.IR fd .
112.TP
113.B EBADF
114.I fd
115is not a valid file descriptor.
a1d5f77c
MK
116.SH "CONFORMING TO"
117SVr4, 4.4BSD, POSIX.1-2001.
fea681da 118.SH NOTES
ee62201f 119The current working directory is the starting point for interpreting
f8a07a21 120relative pathnames (those not starting with \'/\').
ee62201f 121
75fcdb08
MK
122A child process created via
123.BR fork (2)
124inherits its parent's current working directory.
125The current working directory is left unchanged by
126.BR execve (2).
127
fea681da 128The prototype for
e511ffb6 129.BR fchdir ()
fea681da 130is only available if
c13182ef 131.B _BSD_SOURCE
ead83042
MK
132is defined, or
133.B _XOPEN_SOURCE
134is defined with the value 500.
fea681da
MK
135.SH "SEE ALSO"
136.BR chroot (2),
ad7cc990 137.BR getcwd (3),
6a326a85 138.BR path_resolution (7)