| 1 |
'\" t |
| 2 |
.\" Copyright 1995, James R. Van Zandt <[email protected]> |
| 3 |
.\" Copyright 2006-2014, Michael Kerrisk <[email protected]> |
| 4 |
.\" Copyright, the authors of the Linux man-pages project |
| 5 |
.\" |
| 6 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 7 |
.\" |
| 8 |
.TH mkfifo 3 2026-02-08 "Linux man-pages 6.18" |
| 9 |
.SH NAME |
| 10 |
mkfifo, mkfifoat \- make a FIFO special file (a named pipe) |
| 11 |
.SH LIBRARY |
| 12 |
Standard C library |
| 13 |
.RI ( libc ,\~ \-lc ) |
| 14 |
.SH SYNOPSIS |
| 15 |
.nf |
| 16 |
.B #include <sys/types.h> |
| 17 |
.B #include <sys/stat.h> |
| 18 |
.P |
| 19 |
.BI "int mkfifo(const char *" path ", mode_t " mode ); |
| 20 |
.P |
| 21 |
.BR "#include <fcntl.h> " "/* Definition of AT_* constants */" |
| 22 |
.B #include <sys/stat.h> |
| 23 |
.P |
| 24 |
.BI "int mkfifoat(int " dirfd ", const char *" path ", mode_t " mode ); |
| 25 |
.fi |
| 26 |
.P |
| 27 |
.RS -4 |
| 28 |
Feature Test Macro Requirements for glibc (see |
| 29 |
.BR feature_test_macros (7)): |
| 30 |
.RE |
| 31 |
.P |
| 32 |
.BR mkfifoat (): |
| 33 |
.nf |
| 34 |
Since glibc 2.10: |
| 35 |
_POSIX_C_SOURCE >= 200809L |
| 36 |
Before glibc 2.10: |
| 37 |
_ATFILE_SOURCE |
| 38 |
.fi |
| 39 |
.SH DESCRIPTION |
| 40 |
.BR mkfifo () |
| 41 |
makes a FIFO special file with name |
| 42 |
.IR path . |
| 43 |
.I mode |
| 44 |
specifies the FIFO's permissions. |
| 45 |
It is modified by the |
| 46 |
process's |
| 47 |
.B umask |
| 48 |
in the usual way: |
| 49 |
the permissions of the created file are |
| 50 |
.IR "(mode\ &\ \[ti]umask)" . |
| 51 |
.P |
| 52 |
A FIFO special file is similar to a pipe, except that it is created |
| 53 |
in a different way. |
| 54 |
Instead of being an anonymous communications |
| 55 |
channel, a FIFO special file is entered into the filesystem by |
| 56 |
calling |
| 57 |
.BR mkfifo (). |
| 58 |
.P |
| 59 |
Once you have created a FIFO special file in this way, any process can |
| 60 |
open it for reading or writing, in the same way as an ordinary file. |
| 61 |
However, it has to be open at both ends simultaneously before you can |
| 62 |
proceed to do any input or output operations on it. |
| 63 |
Opening a FIFO for reading normally blocks until some |
| 64 |
other process opens the same FIFO for writing, and vice versa. |
| 65 |
See |
| 66 |
.BR fifo (7) |
| 67 |
for nonblocking handling of FIFO special files. |
| 68 |
.SS mkfifoat() |
| 69 |
The |
| 70 |
.BR mkfifoat () |
| 71 |
function operates in exactly the same way as |
| 72 |
.BR mkfifo (), |
| 73 |
except for the differences described here. |
| 74 |
.P |
| 75 |
If |
| 76 |
.I path |
| 77 |
is relative, then it is interpreted relative to the directory |
| 78 |
referred to by the file descriptor |
| 79 |
.I dirfd |
| 80 |
(rather than relative to the current working directory of |
| 81 |
the calling process, as is done by |
| 82 |
.BR mkfifo () |
| 83 |
for a relative pathname). |
| 84 |
.P |
| 85 |
If |
| 86 |
.I path |
| 87 |
is relative and |
| 88 |
.I dirfd |
| 89 |
is the special value |
| 90 |
.BR AT_FDCWD , |
| 91 |
then |
| 92 |
.I path |
| 93 |
is interpreted relative to the current working |
| 94 |
directory of the calling process (like |
| 95 |
.BR mkfifo ()). |
| 96 |
.P |
| 97 |
If |
| 98 |
.I path |
| 99 |
is absolute, then |
| 100 |
.I dirfd |
| 101 |
is ignored. |
| 102 |
.P |
| 103 |
See |
| 104 |
.BR openat (2) |
| 105 |
for an explanation of the need for |
| 106 |
.BR mkfifoat (). |
| 107 |
.SH RETURN VALUE |
| 108 |
On success |
| 109 |
.BR mkfifo () |
| 110 |
and |
| 111 |
.BR mkfifoat () |
| 112 |
return 0. |
| 113 |
On error, \-1 is returned and |
| 114 |
.I errno |
| 115 |
is set to indicate the error. |
| 116 |
.SH ERRORS |
| 117 |
.TP |
| 118 |
.B EACCES |
| 119 |
One of the directories in |
| 120 |
.I path |
| 121 |
did not allow search (execute) permission. |
| 122 |
.TP |
| 123 |
.B EBADF |
| 124 |
.RB ( mkfifoat ()) |
| 125 |
.I path |
| 126 |
is relative but |
| 127 |
.I dirfd |
| 128 |
is neither |
| 129 |
.B AT_FDCWD |
| 130 |
nor a valid file descriptor. |
| 131 |
.TP |
| 132 |
.B EDQUOT |
| 133 |
The user's quota of disk blocks or inodes on the filesystem has been |
| 134 |
exhausted. |
| 135 |
.TP |
| 136 |
.B EEXIST |
| 137 |
.I path |
| 138 |
already exists. |
| 139 |
This includes the case where |
| 140 |
.I path |
| 141 |
is a symbolic link, dangling or not. |
| 142 |
.TP |
| 143 |
.B ENAMETOOLONG |
| 144 |
Either the total size of |
| 145 |
.I path |
| 146 |
is greater than |
| 147 |
.BR PATH_MAX , |
| 148 |
or an individual filename component has a length |
| 149 |
greater than |
| 150 |
.BR NAME_MAX . |
| 151 |
In the GNU system, there is no imposed |
| 152 |
limit on overall filename length, but some filesystems may place |
| 153 |
limits on the length of a component. |
| 154 |
.TP |
| 155 |
.B ENOENT |
| 156 |
A directory component in |
| 157 |
.I path |
| 158 |
does not exist or is a |
| 159 |
dangling symbolic link. |
| 160 |
.TP |
| 161 |
.B ENOSPC |
| 162 |
The directory or filesystem has no room for the new file. |
| 163 |
.TP |
| 164 |
.B ENOTDIR |
| 165 |
A component used as a directory in |
| 166 |
.I path |
| 167 |
is not, in fact, |
| 168 |
a directory. |
| 169 |
.TP |
| 170 |
.B ENOTDIR |
| 171 |
.RB ( mkfifoat ()) |
| 172 |
.I path |
| 173 |
is relative and |
| 174 |
.I dirfd |
| 175 |
is a file descriptor referring to a file other than a directory. |
| 176 |
.TP |
| 177 |
.B EROFS |
| 178 |
.I path |
| 179 |
refers to a read-only filesystem. |
| 180 |
.SH ATTRIBUTES |
| 181 |
For an explanation of the terms used in this section, see |
| 182 |
.BR attributes (7). |
| 183 |
.TS |
| 184 |
allbox; |
| 185 |
lbx lb lb |
| 186 |
l l l. |
| 187 |
Interface Attribute Value |
| 188 |
T{ |
| 189 |
.na |
| 190 |
.nh |
| 191 |
.BR mkfifo (), |
| 192 |
.BR mkfifoat () |
| 193 |
T} Thread safety MT-Safe |
| 194 |
.TE |
| 195 |
.SH VERSIONS |
| 196 |
It is implemented using |
| 197 |
.BR mknodat (2). |
| 198 |
.SH STANDARDS |
| 199 |
POSIX.1-2008. |
| 200 |
.SH HISTORY |
| 201 |
.TP |
| 202 |
.BR mkfifo () |
| 203 |
POSIX.1-2001. |
| 204 |
.TP |
| 205 |
.BR mkfifoat () |
| 206 |
glibc 2.4. |
| 207 |
POSIX.1-2008. |
| 208 |
.SH SEE ALSO |
| 209 |
.BR mkfifo (1), |
| 210 |
.BR close (2), |
| 211 |
.BR open (2), |
| 212 |
.BR read (2), |
| 213 |
.BR stat (2), |
| 214 |
.BR umask (2), |
| 215 |
.BR write (2), |
| 216 |
.BR fifo (7) |