mkfifo(3)

๐Ÿ’… mkfifo(3) โ€” bestie edition

okay so. this is the mkfifo(3) page from the Library Functions Manual, and it's literally about making named pipes. yes, the manual name is right there in the title, we move on ๐Ÿซถ


โœจ NAME โœจ

mkfifo, mkfifoat โ€” make a FIFO special file (a named pipe)

๐Ÿ“š LIBRARY ๐Ÿ“š

Standard C library (libc, -lc)

๐ŸŒธ SYNOPSIS ๐ŸŒธ

#include <sys/types.h>
#include <sys/stat.h>

int mkfifo(const char *path, mode_t mode);

#include <fcntl.h>           /* Definition of AT_* constants */
#include <sys/stat.h>

int mkfifoat(int dirfd, const char *path, mode_t mode);

๐Ÿงš Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

mkfifoat():
    Since glibc 2.10:
        _POSIX_C_SOURCE >= 200809L
    Before glibc 2.10:
        _ATFILE_SOURCE

๐Ÿ’– DESCRIPTION ๐Ÿ’–

So mkfifo() makes a FIFO special file with name path. and mode is what sets the FIFO's permissions. ngl it gets modified by the process's umask the usual way, so the permissions of the created file are literally (mode & ~umask). the math is mathing ๐Ÿ’…

A FIFO special file is like a pipe, except it gets created differently. instead of being an anonymous communications channel, a FIFO special file gets entered into the filesystem when you call mkfifo(). it's giving glow-up, honestly โœจ

Once you've created a FIFO special file like this, any process can open it for reading or writing, same as an ordinary file. HOWEVER โ€” plot twist ๐Ÿ˜ญ โ€” 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. so like, don't just stand there bestie. check fifo(7) for nonblocking handling of FIFO special files, iykyk.

๐Ÿฆ‹ mkfifoat() ๐Ÿฆ‹

mkfifoat() operates in exactly the same way as mkfifo(), except for the differences described here. and the differences are:

  • If path is relative, then it's interpreted relative to the directory referred to by the file descriptor dirfd (rather than relative to the current working directory of the calling process, as is done by mkfifo() for a relative pathname).
  • If path is relative and dirfd is the special value AT_FDCWD, then path is interpreted relative to the current working directory of the calling process (like mkfifo()).
  • If path is absolute, then dirfd is ignored. periodt.

See openat(2) for an explanation of the need for mkfifoat().

๐ŸŽ€ RETURN VALUE ๐ŸŽ€

On success, mkfifo() and mkfifoat() return 0. that's the slay. ๐Ÿฅณ

On error, -1 is returned and errno is set to indicate the error. the vibe check failed bestie ๐Ÿ’€

๐Ÿ”ฅ ERRORS ๐Ÿ”ฅ

  • EACCES โ€” one of the directories in path did not allow search (execute) permission. rude.
  • EBADF โ€” (mkfifoat()) path is relative but dirfd is neither AT_FDCWD nor a valid file descriptor.
  • EDQUOT โ€” the user's quota of disk blocks or inodes on the filesystem has been exhausted. no more room, no more slay.
  • EEXIST โ€” path already exists. and yes, this includes the case where path is a symbolic link, dangling or not. iconic behavior, honestly.
  • ENAMETOOLONG โ€” either the total size of path is greater than PATH_MAX, or an individual filename component has a length greater than NAME_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.
  • ENOENT โ€” a directory component in path does not exist or is a dangling symbolic link. she's not home ๐Ÿ’”
  • ENOSPC โ€” the directory or filesystem has no room for the new file.
  • ENOTDIR โ€” a component used as a directory in path is not, in fact, a directory.
  • ENOTDIR โ€” (mkfifoat()) path is relative and dirfd is a file descriptor referring to a file other than a directory. yes this one shows up twice in the original, we don't make the rules ๐Ÿ’…
  • EROFS โ€” path refers to a read-only filesystem. read-only era, respect it.

๐Ÿ‘‘ ATTRIBUTES ๐Ÿ‘‘

For an explanation of the terms used in this section, see attributes(7).

  • Interface: mkfifo(), mkfifoat()
  • Attribute: Thread safety
  • Value: MT-Safe

(that's the whole table, she's small but mighty ๐Ÿซถ)

โญ VERSIONS โญ

It is implemented using mknodat(2). lowkey that's the whole tea.

๐ŸŒˆ STANDARDS ๐ŸŒˆ

POSIX.1-2008.

๐Ÿ“œ HISTORY ๐Ÿ“œ

  • mkfifo() โ€” POSIX.1-2001.
  • mkfifoat() โ€” glibc 2.4. POSIX.1-2008.

๐Ÿ’œ SEE ALSO ๐Ÿ’œ

mkfifo(1), close(2), open(2), read(2), stat(2), umask(2), write(2), fifo(7)


that's the whole page bestie, go make some pipes ๐Ÿ’–

signing off with the receipts: this is from Linux man-pages 6.20, dated 2026-02-08, and the page name up top was mkfifo(3). no cap, not one detail dropped. mwah ๐Ÿ˜˜

๐Ÿ“ฆ where this page comes from
  • arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • ๐Ÿ“œ the page's license: Linux-man-pages-copyleft
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms