1GETWD(3P)                  POSIX Programmer's Manual                 GETWD(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       getwd - get the current working directory pathname (LEGACY)
13

SYNOPSIS

15       #include <unistd.h>
16
17       char *getwd(char *path_name);
18
19

DESCRIPTION

21       The getwd() function shall determine an absolute pathname of  the  cur‐
22       rent  working  directory of the calling process, and copy a string con‐
23       taining that pathname into the array pointed to by the path_name  argu‐
24       ment.
25
26       If  the  length  of  the  pathname  of the current working directory is
27       greater than ({PATH_MAX}+1) including the null byte, getwd() shall fail
28       and return a null pointer.
29

RETURN VALUE

31       Upon  successful  completion,  a  pointer  to the string containing the
32       absolute pathname of the current working directory shall  be  returned.
33       Otherwise,  getwd() shall return a null pointer and the contents of the
34       array pointed to by path_name are undefined.
35

ERRORS

37       No errors are defined.
38
39       The following sections are informative.
40

EXAMPLES

42       None.
43

APPLICATION USAGE

45       For applications portability, the getcwd() function should be  used  to
46       determine the current working directory instead of getwd().
47

RATIONALE

49       Since  the  user  cannot  specify  the  length  of the buffer passed to
50       getwd(), use of this function is discouraged. The length of a  pathname
51       described  in {PATH_MAX} is file system-dependent and may vary from one
52       mount point to another, or might even be unlimited. It is  possible  to
53       overflow this buffer in such a way as to cause applications to fail, or
54       possible system security violations.
55
56       It is recommended that the getcwd() function should be used  to  deter‐
57       mine the current working directory.
58

FUTURE DIRECTIONS

60       This function may be withdrawn in a future version.
61

SEE ALSO

63       getcwd(),   the   Base   Definitions  volume  of  IEEE Std 1003.1-2001,
64       <unistd.h>
65
67       Portions of this text are reprinted and reproduced in  electronic  form
68       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
69       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
70       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
71       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
72       event of any discrepancy between this version and the original IEEE and
73       The Open Group Standard, the original IEEE and The Open Group  Standard
74       is  the  referee document. The original Standard can be obtained online
75       at http://www.opengroup.org/unix/online.html .
76
77
78
79IEEE/The Open Group                  2003                            GETWD(3P)
Impressum