MKFIFO(3C) | Standard C Library Functions | MKFIFO(3C) |
mkfifo, mkfifoat - make a FIFO special file
#include <sys/types.h> #include <sys/stat.h> int mkfifo(const char *path, mode_t mode);
int mkfifoat(int fd, const char *path, mode_t mode);
The mkfifo() and mkfifoat() functions create a new FIFO special file named by the pathname pointed to by path. The file permission bits of the new FIFO are initialized from mode. The file permission bits of the mode argument are modified by the process's file creation mask (see umask(2)). Bits other than the file permission bits in mode are ignored.
If path names a symbolic link, mkfifo() and mkfifoat() fail and set errno to EEXIST.
The FIFO's user ID is set to the process's effective user ID. The FIFO's group ID is set to the group ID of the parent directory or to the effective group ID of the process.
The mkfifoat() function is equivalent to mkfifo(); however, if path is a relative path, then it is resolved start at the directory represented by fd. fd may be set to the special value of AT_FDCWD which indicates that the current working directory should be used to start resolving path.
The mkfifo() function calls mknod(2) to create the file. The mkfifoat() function calls mknodat(2) to create the file.
Upon successful completion, mkfifo() and mkfifoat() mark for update the st_atime, st_ctime, and st_mtime fields of the file. Also, the st_ctime and st_mtime fields of the directory that contains the new entry are marked for update.
Upon successful completion, 0 is returned. Otherwise, −1 is returned and errno is set to indicate the error.
The mkfifo() and mkfifoat() functions will fail if:
EACCES
EEXIST
ELOOP
ENAMETOOLONG
ENOENT
ENOSPC
ENOTDIR
EROFS
The mkfifoat() function will fail if:
EBADF
The mkfifo() function may fail if:
ELOOP
ENAMETOOLONG
Example 1 Create a FIFO File
The following example demonstrates how to create a FIFO file named /home/cnd/mod_done with read and write permissions for the owner and read permissions for the group and others.
#include <sys/types.h> #include <sys/stat.h> int status; ... status = mkfifo("/home/cnd/mod_done", S_IWUSR | S_IRUSR |
S_IRGRP | S_IROTH);
See attributes(7) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
Interface Stability | Standard |
MT-Level | MT-Safe |
mkdir(1), chmod(2), exec(2), mknod(2), umask(2), stat.h(3HEAD), ufs(4FS), attributes(7), standards(7)
June 18, 2021 | OmniOS |