| Name: _____________________ | Class: CET 421 |
| SSN/ID: _____________________ | Section & Group: ____________ |
|
#include <unistd.h> int chdir(const char * pathname); Returns: 0 if OK, -1 on error |
Every process has a current working directory. This directory is where the search for all relative pathnames starts (all pathnames that do not begin with a slash). When a user logs on to a UNIX system, the current working directory normally starts at the directory specified in the /etc/passwd file - the user's "home" directory. The current working directory is an attribute of a process; the home directory is an attribute of a login name. You can change the current working directory of the calling process by calling the chdir function.
pathname can be absolute or relative and can start with (or be) the relative strings "." and "..".
Enter the man chdir command on your system to get a more detailed description of this function.
Note: The chdir function does NOT change the PWD environment variable.
The descriptions of the system functions above are drawn from sources that include
manuals on the Sun Solaris system and the MAC OS X Darwin/BDS system, and also from 'Advanced Programming in the UNIX Environment', W. Richard Stevens, Addison-Wesley, 1993.