File: mkfifo.3

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