Syntax | #include <sys/stat.h> Optional #include <sys/types.h> (End) int mkfifo(const char *path, mode_t mode); int mkfifoat(int fd, const char *path, mode_t mode); |
Description | mkfifo() creates a new FIFO special file (FIFO for short) with the pathname path. The access mode of the new FIFO is initialized from mode. The file permission bits of the mode argument are modified by the process' file creation mask (see umask() ).
The user ID of the FIFO is set to the effective user ID of the process, and the group ID of the FIFO is set to the effective group ID of the process, unless the S_ISGID bit is set in the parent directory, in which case the group ID of the FIFO is inherited from the parent directory. Upon successful completion, mkfifo() will mark for update the st_atime , st_ctime and st_mtime fields of the file. The st_ctime and st_mtime fields of the directory that contains the new entry are also updated (see sys/stat.h ). The mkfifoat() function is equivalent to the mkfifo() function except when the path parameter specifies a relative path. In this case the new FIFO device file is not created in the current directory, but in the directory connected with the file descriptor fd. If the file descriptor was opened without O_SEARCH , the function checks whether a search is permitted in the connected file descriptor with the authorizations applicable for the directory. If the file descriptor was opened with O_SEARCH , the check is not performed. When the value AT_FDCWD is transferred to the mkfifoat() function for the fd parameter, the current directory is used. |
Return val. | 0 | if successful. |
| -1 | if no FIFO was created. errno is set to indicate the error. |
Errors | mkfifo() and mkfifoat() will fail if:
|
| EACCES
| Either no search permission exists for a component of the path, or no write permission exists for the parent directory of the new FIFO file. |
| EEXIST
| The specified file already exists. |
| ELOOP
| Too many symbolic links were encountered during in resolving path. |
| Extension |
| EINVAL
| An attempt was made to access a BS2000 file. (End) |
| ENAMETOOLONG
|
|
| The length of the path argument exceeds {PATH_MAX} or a pathname component is longer than {NAME_MAX} and {_POSIX_NO_TRUNC} is set. |
| ENOENT
| A component of the path prefix does not exist or path points to an empty string. |
| ENOSPC
| The directory that would contain the new file cannot be extended or the file system is out of file-allocation resources. |
| ENOTDIR
| A component of the path prefix is not a directory. |
| EROFS
| specified file resides on a read-only file system. |
| In addition, mkfifoat() fails if the following applies: |
| EACCES
| The file descriptor fd was not opened with O_SEARCH , and the authorizations applicable for the directory do not permit the directory to be searched. |
| EBADF
| The path parameter does not specify an absolute pathname, and the fd parameter does not have the value AT_FDCWD , nor does it contain a valid file descriptor opened for reading or searching. |
| ENOTDIR
| The path parameter does not specify an absolute pathname, and the file descriptor fd is not connected with a directory. |
Notes | Bits other than the file permission bits in mode are ignored. path can only be a POSIX file. |
See also | umask() , fcntl.h , sys/stat.h , sys/types.h .
|