.TH _getwd() "" "" "General Function (libc)"
.PC "Get current working directory name"
\fBchar *_getwd(\fIpathname\fB)\fR
\fBchar *\fIpathname\^\fB;\fR
.PP
The
.I "current working directory"
is the directory from which file name searches commence
when a path name does not begin with `/'.
.B _getwd()
returns the name of the current working directory.
It is useful for processes like spoolers and daemons,
which must generate full path names for files.
.PP
If you do not have permission
to search all levels of the directory hierarchy above the current directory,
.B _getwd()
cannot obtain the directory name for you.
.SH "See Also"
.Xr "chdir()," chdir.s
.Xr "getcwd()," getcwd
.Xr "libc," libc
.Xr "pwd" pwd
.SH Diagnostics
.B _getwd()
returns NULL and writes an error message into
.I pathname
if an error occurs, e.g.,
if the current directory cannot be found
or if any other error occurs.
.SH Notes
.B _getwd()
is obsolete, and is included for reasons of compatibility.
Programmers should use the function
.B getcwd()
instead.
.PP
.B _getwd()
fails if the current directory name is longer than
MAXPATH characters (128 characters as defined in header file
.BR <path.h> ).
The chunk of memory pointed to by
.I pathname
must be big enough to hold
.B MAXPATHLEN
characters plus a trailing NUL.
.PP
If
.B _getwd()
fails,
the working directory cannot be restored to its initial value.
.PP
The name of this function has been change to
.B _getwd()
to avoid confusion with the Berkeley \*(UN function
.BR getwd() ,
which has a different calling sequence.
