MKFIFO(2)
π MKFIFO π
hi bestie π so this lil cutie lives in section 2 of the System Calls Manual, and it's giving "I make fifo files and I do it flawlessly". no cap. let's get into it.
πΈ NAME πΈ
mkfifo, mkfifoat β make a fifo file π
π LIBRARY π
Standard C Library (libc, -lc) β¨
π SYNOPSIS π
#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);
π DESCRIPTION π
okay so mkfifo() is the system call that creates a brand new fifo file, and its name is path π«Ά. the access permissions? those come from mode, and they get restricted by the umask(2) of whatever process is doing the calling. yes, your umask is always in the group chat, always has opinions.
the fifo's owner ID is set to the process's effective user ID π. and the fifo's group ID? that gets set to the group of the parent directory it's created in. it's giving "inherited the family group chat" energy fr fr.
now mkfifoat() is literally the same as mkfifo() except when path is a relative path π. in that specific case, the newly created FIFO gets created relative to the directory associated with the file descriptor fd, instead of the current working directory. main character behaviour honestly. and if you pass mkfifoat() the special value AT_FDCWD in the fd parameter? then the current working directory is used and the behaviour is identical to calling mkfifo(). twin behaviour, no notes πβ¨
π RETURN VALUES π
mkfifo() returns the value 0 if it slayed (successful, obviously). otherwise it returns the value -1 and the global variable errno gets set to indicate the error π. so yeah, check your errno bestie.
π ERRORS π
β οΈ heads up: the mkfifo() system call will fail and no fifo will be created if any of these happen:
[ENOTSUP]β the kernel has not been configured to support fifo's π[ENOTDIR]β a component of the path prefix is not a directory π[ENAMETOOLONG]β a component of a pathname exceeded255characters, or an entire path name exceeded1023characters π[ENOENT]β a component of the path prefix does not exist π»[EACCES]β a component of the path prefix denies search permission, or write permission is denied on the parent directory of the fifo to be created π«[ELOOP]β too many symbolic links were encountered in translating the pathname π[EROFS]β the named file would reside on a read-only file system π§[EEXIST]β the named file exists. it's already there bestie, you can't sit with us π[EPERM]β the parent directory of the named file has its immutable flag set, see thechflags(2)manual page for more information π[ENOSPC]β the directory in which the entry for the new fifo is being placed cannot be extended because there is no space left on the file system containing the directory π[ENOSPC]β there are no free inodes on the file system on which the fifo is being created π[EDQUOT]β the directory in which the entry for the new fifo is being placed cannot be extended because the user's quota of disk blocks on the file system containing the directory has been exhausted πΈ[EDQUOT]β the user's quota of inodes on the file system on which the fifo is being created has been exhausted πΈ[EIO]β an I/O error occurred while making the directory entry or allocating the inode β‘[EINTEGRITY]β corrupted data was detected while reading from the file system π§¨[EFAULT]β thepathargument points outside the process's allocated address space π¨
and on top of all the errors that mkfifo() returns, mkfifoat() might also fail if:
[EBADF]β thepathargument does not specify an absolute path and thefdargument is neitherAT_FDCWDnor a valid file descriptor open for searching π΅[ENOTDIR]β thepathargument is not an absolute path andfdis neitherAT_FDCWDnor a file descriptor associated with a directory π΅
π¦ SEE ALSO π¦
chflags(2), chmod(2), mknod(2), stat(2), umask(2) β go read these too, they're all iconic in their own way π
β STANDARDS β
the mkfifo() system call is expected to conform to ISO/IEC 9945-1:1990 (βPOSIX.1β) π. and the mkfifoat() system call follows The Open Group Extended API Set 2 specification π«Ά. standards queen behaviour, we love to see it.
π HISTORY π
the mkfifoat() system call appeared in FreeBSD 8.0 π. a legend was born.
and that's the whole page bestie!! this one shipped from Debian and it's dated March 30, 2020 π now go make some fifos, you absolute icon πβ¨
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 1990, 1991, 1993 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms