getwd Subroutine

Purpose

Gets current directory path name.

Library

Standard C Library (libc.a)

Syntax

#include <unistd.h>

char *getwd ( PathName)
char *PathName;

Description

The getwd subroutine determines the absolute path name of the current directory, then copies that path name into the area pointed to by the PathName parameter.

The maximum path-name length, in characters, is set by the PATH_MAX value, as specified in the limits.h file.

Parameters

Item Description
PathName Points to the full path name.

Return Values

If the call to the getwd subroutine is successful, a pointer to the absolute path name of the current directory is returned. If an error occurs, the getwd subroutine returns a null value and places an error message in the PathName parameter.

In UNIX03 mode, the getwd subroutine returns a null value if the actual path name is longer than the value defined by PATH_MAX. In the previous mode, the getwd subroutine returns a truncated path name if the path name is longer than PATH_MAX. The previous behavior can be disabled setting the environment variable XPG_SUS_ENV=ON.