NAME |LIBRARY |SYNOPSIS |DESCRIPTION |RETURN VALUE |ERRORS |ATTRIBUTES |VERSIONS |STANDARDS |HISTORY |SEE ALSO |COLOPHON | |
mkfifo(3) Library Functions Manualmkfifo(3)mkfifo, mkfifoat - make a FIFO special file (a named pipe)
Standard C library (libc,-lc)
#include <sys/types.h>#include <sys/stat.h>int mkfifo(const char *path, mode_tmode);#include <fcntl.h>/* Definition of AT_* constants */#include <sys/stat.h>int mkfifoat(intdirfd, const char *path, mode_tmode); Feature Test Macro Requirements for glibc (seefeature_test_macros(7)):mkfifoat(): Since glibc 2.10: _POSIX_C_SOURCE >= 200809L Before glibc 2.10: _ATFILE_SOURCE
mkfifo() makes a FIFO special file with namepath.mode specifies the FIFO's permissions. It is modified by the process'sumaskin the usual way: the permissions of the created file are(mode & ~umask). A FIFO special file is similar to a pipe, except that it is created in a different way. Instead of being an anonymous communications channel, a FIFO special file is entered into the filesystem by callingmkfifo(). Once you have created a FIFO special file in this way, any process can open it for reading or writing, in the same way as an ordinary file. However, it has to be open at both ends simultaneously before you can proceed to do any input or output operations on it. Opening a FIFO for reading normally blocks until some other process opens the same FIFO for writing, and vice versa. Seefifo(7) for nonblocking handling of FIFO special files.mkfifoat() Themkfifoat() function operates in exactly the same way asmkfifo(), except for the differences described here. Ifpath is relative, then it is interpreted relative to the directory referred to by the file descriptordirfd (rather than relative to the current working directory of the calling process, as is done bymkfifo() for a relative pathname). Ifpath is relative anddirfd is the special valueAT_FDCWD, thenpath is interpreted relative to the current working directory of the calling process (likemkfifo()). Ifpath is absolute, thendirfd is ignored. Seeopenat(2) for an explanation of the need formkfifoat().
On successmkfifo() andmkfifoat() return 0. On error, -1 is returned anderrno is set to indicate the error.
EACCESOne of the directories inpath did not allow search (execute) permission.EBADF(mkfifoat())path is relative butdirfd is neitherAT_FDCWD nor a valid file descriptor.EDQUOTThe user's quota of disk blocks or inodes on the filesystem has been exhausted.EEXISTpath already exists. This includes the case wherepath is a symbolic link, dangling or not.ENAMETOOLONG Either the total size ofpath is greater thanPATH_MAX, or an individual filename component has a length greater thanNAME_MAX. In the GNU system, there is no imposed limit on overall filename length, but some filesystems may place limits on the length of a component.ENOENTA directory component inpath does not exist or is a dangling symbolic link.ENOSPCThe directory or filesystem has no room for the new file.ENOTDIR A component used as a directory inpath is not, in fact, a directory.ENOTDIR (mkfifoat())path is relative anddirfd is a file descriptor referring to a file other than a directory.EROFSpath refers to a read-only filesystem.
For an explanation of the terms used in this section, seeattributes(7). ┌──────────────────────────────────────┬───────────────┬─────────┐ │Interface│Attribute│Value│ ├──────────────────────────────────────┼───────────────┼─────────┤ │mkfifo(),mkfifoat() │ Thread safety │ MT-Safe │ └──────────────────────────────────────┴───────────────┴─────────┘
It is implemented usingmknodat(2).
POSIX.1-2008.
mkfifo() POSIX.1-2001.mkfifoat() glibc 2.4. POSIX.1-2008.
mkfifo(1),close(2),open(2),read(2),stat(2),umask(2),write(2),fifo(7)
This page is part of theman-pages (Linux kernel and C library user-space interface documentation) project. Information about the project can be found at ⟨https://www.kernel.org/doc/man-pages/⟩. If you have a bug report for this manual page, see ⟨https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING⟩. This page was obtained from the tarball man-pages-6.15.tar.gz fetched from ⟨https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/⟩ on 2025-08-11. If you discover any rendering problems in this HTML version of the page, or you believe there is a better or more up- to-date source for the page, or you have corrections or improvements to the information in this COLOPHON (which isnot part of the original manual page), send a mail to man-pages@man7.orgLinux man-pages 6.15 2025-05-17mkfifo(3)Pages that refer to this page:mkfifo(1), mknod(2), open(2), umask(2), unlink(2), remove(3), fifo(7), pipe(7), signal-safety(7)
HTML rendering created 2025-09-06 byMichael Kerrisk, author ofThe Linux Programming Interface. For details of in-depthLinux/UNIX system programming training courses that I teach, lookhere. Hosting byjambit GmbH. | ![]() |