mount_setattr.2: Further tweaks after feedback from Christian Brauner
[man-pages.git] / man3 / mkfifo.3
blob3aba5498cc1965a29e73de328a91e6bbbfc8b061
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 EDQUOT
135 The user's quota of disk blocks or inodes on the filesystem has been
136 exhausted.
138 .B EEXIST
139 \fIpathname\fP already exists.
140 This includes the case where
141 .I pathname
142 is a symbolic link, dangling or not.
144 .B ENAMETOOLONG
145 Either the total length of \fIpathname\fP is greater than
146 \fBPATH_MAX\fP, or an individual filename component has a length
147 greater than \fBNAME_MAX\fP.
148 In the GNU system, there is no imposed
149 limit on overall filename length, but some filesystems may place
150 limits on the length of a component.
152 .B ENOENT
153 A directory component in \fIpathname\fP does not exist or is a
154 dangling symbolic link.
156 .B ENOSPC
157 The directory or filesystem has no room for the new file.
159 .B ENOTDIR
160 A component used as a directory in \fIpathname\fP is not, in fact, a
161 directory.
163 .B EROFS
164 \fIpathname\fP refers to a read-only filesystem.
166 The following additional errors can occur for
167 .BR mkfifoat ():
169 .B EBADF
170 .I pathname
171 is relative but
172 .I dirfd
173 is neither
174 .B AT_FDCWD
175 nor a valid file descriptor.
177 .B ENOTDIR
178 .I pathname
179 is a relative pathname and
180 .I dirfd
181 is a file descriptor referring to a file other than a directory.
182 .SH VERSIONS
183 .BR mkfifoat ()
184 was added to glibc in version 2.4.
185 It is implemented using
186 .BR mknodat (2),
187 available on Linux since kernel 2.6.16.
188 .SH ATTRIBUTES
189 For an explanation of the terms used in this section, see
190 .BR attributes (7).
191 .ad l
194 allbox;
195 lbx lb lb
196 l l l.
197 Interface       Attribute       Value
199 .BR mkfifo (),
200 .BR mkfifoat ()
201 T}      Thread safety   MT-Safe
205 .sp 1
206 .SH CONFORMING TO
207 .BR mkfifo ():
208 POSIX.1-2001, POSIX.1-2008.
210 .BR mkfifoat ():
211 POSIX.1-2008.
212 .SH SEE ALSO
213 .BR mkfifo (1),
214 .BR close (2),
215 .BR open (2),
216 .BR read (2),
217 .BR stat (2),
218 .BR umask (2),
219 .BR write (2),
220 .BR fifo (7)