![]() |
![]() |
chdir
- Change Directory FunctionThe left arrow above will return you to
the Home page
The left arrows below will return you to the Previous page
![]() |
![]() |
![]() |
#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
man
uals 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.
![]() |
![]() |
![]() |
For use only by students and instructors using the supplementary material available with the text book: "Operating Systems - Internals and Design Principles", William Stallings, Prentice Hall, 5th Edition, 2004. Not to be printed out or copied by any other persons or used for any other purpose without written permission of the author(s).
©