版權所有 © 2014 tutorialspoint
chdir、fchdir - 更改工作目錄
#include <unistd.h> int chdir(const char *path); int fchdir(int fd);
int chdir(const char *path); int fchdir(int fd);
chdir() 將當前工作目錄更改為path中指定的工作目錄。fchdir() 與chdir() 相同;唯一的區別在於目錄作為開啟的檔案描述符給出。
成功時,返回零。錯誤時,返回 -1,並且errno被相應地設定。
根據檔案系統,可以返回其他錯誤。下面列出了chdir() 的更一般的錯誤
透過fork(2) 建立的子程序繼承其父程序的當前工作目錄。execve(2) 不更改當前工作目錄。
僅當定義了_BSD_SOURCE或_XOPEN_SOURCE且值為 500 時,fchdir() 的原型才可用。
SVr4、4.4BSD、POSIX.1-2001。
chroot (2)
path_resolution (2)
廣告