fchdir

Changes the current working directory to the specified directory.

Library:LibC
Classification:POSIX
Service:File and Directory I/O

Syntax

  #include <unistd.h> 
   
  int fchdir (
     int   fildes);
  

Parameters

fildes

(IN) Specifies a file descriptor that references a directory. If it references a file, fchdir sets errno to ENOTDIR.

Return Values

If successful, returns 0. Otherwise, returns -1 and sets errno to one of the following. On failure, the current working directory remains unchanged.

Decimal

Constant

Description

4

EBADF

The file descriptor is invalid.

6

EACCES

Search permission is denied on the specified directory.

63

EINTR

The function was interrupted.

67

ENOTDIR

The file descriptor does not specify a directory.

Remarks

The fchdir function causes the directory named by the fildes parameter to become the current working directory for all threads of a virtual machine. It becomes the starting point for path searches for pathnames not beginning with “/”.

See Also