fchmod - change mode of a file
#include <sys/stat.h> int fchmod(int fildes, mode_t mode);
The fchmod() function has the same effect as chmod() except that the file whose permissions are to be changed is specified by the file descriptor fildes.
If the Shared Memory Objects option is supported, and fildes references a shared memory object, the fchmod() function need only affect the S_IRUSR, S_IWUSR, S_IRGRP, S_IWGRP, S_IROTH, and S_IWOTH file permission bits.
Upon successful completion, fchmod() returns 0. Otherwise, it returns -1 and sets errno to indicate the error.
The fchmod() function will fail if:
- The fildes argument is not an open file descriptor.
- The effective user ID does not match the owner of the file and the process does not have appropriate privilege.
- The file referred to by fildes resides on a read-only file system.
The fchmod() function may fail if:
- The fchmod() function was interrupted by a signal.
- The value of the mode argument is invalid.
- The fildes argument refers to a pipe and the implementation disallows execution of fchmod() on a pipe.
chmod(), chown(), creat(), fcntl(), fstatvfs(), mknod(), open(), read(), stat(), write(), <sys/stat.h>.