Changes: Ready for 5.13
[man-pages.git] / man3 / mkfifo.3
bloba0c5789394ba6f1e0573b810cddd511390f6c2f0
1 .\" This manpage is Copyright (C) 1995 James R. Van Zandt <jrv@vanzandt.mv.com>
2 .\" and Copyright (C) 2006, 2014 Michael Kerrisk
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .\" changed section from 2 to 3, aeb, 950919
27 .\"
28 .TH MKFIFO 3 2021-03-22 "GNU" "Linux Programmer's Manual"
29 .SH NAME
30 mkfifo, mkfifoat \- make a FIFO special file (a named pipe)
31 .SH SYNOPSIS
32 .nf
33 .B #include <sys/types.h>
34 .B #include <sys/stat.h>
35 .PP
36 .BI "int mkfifo(const char *" pathname ", mode_t " mode );
37 .PP
38 .BR "#include <fcntl.h>           " "/* Definition of AT_* constants */"
39 .B #include <sys/stat.h>
40 .PP
41 .BI "int mkfifoat(int " dirfd ", const char *" pathname ", mode_t " mode );
42 .fi
43 .PP
44 .RS -4
45 Feature Test Macro Requirements for glibc (see
46 .BR feature_test_macros (7)):
47 .RE
48 .PP
49 .BR mkfifoat ():
50 .nf
51     Since glibc 2.10:
52         _POSIX_C_SOURCE >= 200809L
53     Before glibc 2.10:
54         _ATFILE_SOURCE
55 .fi
56 .SH DESCRIPTION
57 .BR mkfifo ()
58 makes a FIFO special file with name \fIpathname\fP.
59 \fImode\fP specifies the FIFO's permissions.
60 It is modified by the
61 process's \fBumask\fP in the usual way: the permissions of the created
62 file are \fB(\fP\fImode\fP\fB & \(tiumask)\fP.
63 .PP
64 A FIFO special file is similar to a pipe, except that it is created
65 in a different way.
66 Instead of being an anonymous communications
67 channel, a FIFO special file is entered into the filesystem by
68 calling
69 .BR mkfifo ().
70 .PP
71 Once you have created a FIFO special file in this way, any process can
72 open it for reading or writing, in the same way as an ordinary file.
73 However, it has to be open at both ends simultaneously before you can
74 proceed to do any input or output operations on it.
75 Opening a FIFO for reading normally blocks until some
76 other process opens the same FIFO for writing, and vice versa.
77 See
78 .BR fifo (7)
79 for nonblocking handling of FIFO special files.
80 .SS mkfifoat()
81 The
82 .BR mkfifoat ()
83 function operates in exactly the same way as
84 .BR mkfifo (),
85 except for the differences described here.
86 .PP
87 If the pathname given in
88 .I pathname
89 is relative, then it is interpreted relative to the directory
90 referred to by the file descriptor
91 .I dirfd
92 (rather than relative to the current working directory of
93 the calling process, as is done by
94 .BR mkfifo ()
95 for a relative pathname).
96 .PP
98 .I pathname
99 is relative and
100 .I dirfd
101 is the special value
102 .BR AT_FDCWD ,
103 then
104 .I pathname
105 is interpreted relative to the current working
106 directory of the calling process (like
107 .BR mkfifo ()).
110 .I pathname
111 is absolute, then
112 .I dirfd
113 is ignored.
116 .BR openat (2)
117 for an explanation of the need for
118 .BR mkfifoat ().
119 .SH RETURN VALUE
120 On success
121 .BR mkfifo ()
123 .BR mkfifoat ()
124 return 0.
125 On error, \-1 is returned and
126 .I errno
127 is set to indicate the error.
128 .SH ERRORS
130 .B EACCES
131 One of the directories in \fIpathname\fP did not allow search
132 (execute) permission.
134 .B EBADF
135 .RB ( mkfifoat ())
136 .I pathname
137 is relative but
138 .I dirfd
139 is neither
140 .B AT_FDCWD
141 nor a valid file descriptor.
143 .B EDQUOT
144 The user's quota of disk blocks or inodes on the filesystem has been
145 exhausted.
147 .B EEXIST
148 \fIpathname\fP already exists.
149 This includes the case where
150 .I pathname
151 is a symbolic link, dangling or not.
153 .B ENAMETOOLONG
154 Either the total length of \fIpathname\fP is greater than
155 \fBPATH_MAX\fP, or an individual filename component has a length
156 greater than \fBNAME_MAX\fP.
157 In the GNU system, there is no imposed
158 limit on overall filename length, but some filesystems may place
159 limits on the length of a component.
161 .B ENOENT
162 A directory component in \fIpathname\fP does not exist or is a
163 dangling symbolic link.
165 .B ENOSPC
166 The directory or filesystem has no room for the new file.
168 .B ENOTDIR
169 A component used as a directory in \fIpathname\fP is not, in fact, a
170 directory.
172 .B ENOTDIR
173 .RB ( mkfifoat ())
174 .I pathname
175 is a relative pathname and
176 .I dirfd
177 is a file descriptor referring to a file other than a directory.
179 .B EROFS
180 \fIpathname\fP refers to a read-only filesystem.
181 .SH VERSIONS
182 .BR mkfifoat ()
183 was added to glibc in version 2.4.
184 It is implemented using
185 .BR mknodat (2),
186 available on Linux since kernel 2.6.16.
187 .SH ATTRIBUTES
188 For an explanation of the terms used in this section, see
189 .BR attributes (7).
190 .ad l
193 allbox;
194 lbx lb lb
195 l l l.
196 Interface       Attribute       Value
198 .BR mkfifo (),
199 .BR mkfifoat ()
200 T}      Thread safety   MT-Safe
204 .sp 1
205 .SH CONFORMING TO
206 .BR mkfifo ():
207 POSIX.1-2001, POSIX.1-2008.
209 .BR mkfifoat ():
210 POSIX.1-2008.
211 .SH SEE ALSO
212 .BR mkfifo (1),
213 .BR close (2),
214 .BR open (2),
215 .BR read (2),
216 .BR stat (2),
217 .BR umask (2),
218 .BR write (2),
219 .BR fifo (7)