]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/mkfifo.3
c9598ea7265019a6f37e98e7073efad217f2efa6
[thirdparty/man-pages.git] / man3 / mkfifo.3
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 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .\" changed section from 2 to 3, aeb, 950919
7 .\"
8 .TH MKFIFO 3 2021-08-27 "Linux man-pages (unreleased)" "Linux Programmer's Manual"
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 .PP
19 .BI "int mkfifo(const char *" pathname ", mode_t " mode );
20 .PP
21 .BR "#include <fcntl.h> " "/* Definition of AT_* constants */"
22 .B #include <sys/stat.h>
23 .PP
24 .BI "int mkfifoat(int " dirfd ", const char *" pathname ", mode_t " mode );
25 .fi
26 .PP
27 .RS -4
28 Feature Test Macro Requirements for glibc (see
29 .BR feature_test_macros (7)):
30 .RE
31 .PP
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 \fIpathname\fP.
42 \fImode\fP specifies the FIFO's permissions.
43 It is modified by the
44 process's \fBumask\fP in the usual way: the permissions of the created
45 file are \fB(\fP\fImode\fP\fB & \(tiumask)\fP.
46 .PP
47 A FIFO special file is similar to a pipe, except that it is created
48 in a different way.
49 Instead of being an anonymous communications
50 channel, a FIFO special file is entered into the filesystem by
51 calling
52 .BR mkfifo ().
53 .PP
54 Once you have created a FIFO special file in this way, any process can
55 open it for reading or writing, in the same way as an ordinary file.
56 However, it has to be open at both ends simultaneously before you can
57 proceed to do any input or output operations on it.
58 Opening a FIFO for reading normally blocks until some
59 other process opens the same FIFO for writing, and vice versa.
60 See
61 .BR fifo (7)
62 for nonblocking handling of FIFO special files.
63 .SS mkfifoat()
64 The
65 .BR mkfifoat ()
66 function operates in exactly the same way as
67 .BR mkfifo (),
68 except for the differences described here.
69 .PP
70 If the pathname given in
71 .I pathname
72 is relative, then it is interpreted relative to the directory
73 referred to by the file descriptor
74 .I dirfd
75 (rather than relative to the current working directory of
76 the calling process, as is done by
77 .BR mkfifo ()
78 for a relative pathname).
79 .PP
80 If
81 .I pathname
82 is relative and
83 .I dirfd
84 is the special value
85 .BR AT_FDCWD ,
86 then
87 .I pathname
88 is interpreted relative to the current working
89 directory of the calling process (like
90 .BR mkfifo ()).
91 .PP
92 If
93 .I pathname
94 is absolute, then
95 .I dirfd
96 is ignored.
97 .PP
98 See
99 .BR openat (2)
100 for an explanation of the need for
101 .BR mkfifoat ().
102 .SH RETURN VALUE
103 On success
104 .BR mkfifo ()
105 and
106 .BR mkfifoat ()
107 return 0.
108 On error, \-1 is returned and
109 .I errno
110 is set to indicate the error.
111 .SH ERRORS
112 .TP
113 .B EACCES
114 One of the directories in \fIpathname\fP did not allow search
115 (execute) permission.
116 .TP
117 .B EBADF
118 .RB ( mkfifoat ())
119 .I pathname
120 is relative but
121 .I dirfd
122 is neither
123 .B AT_FDCWD
124 nor a valid file descriptor.
125 .TP
126 .B EDQUOT
127 The user's quota of disk blocks or inodes on the filesystem has been
128 exhausted.
129 .TP
130 .B EEXIST
131 \fIpathname\fP already exists.
132 This includes the case where
133 .I pathname
134 is a symbolic link, dangling or not.
135 .TP
136 .B ENAMETOOLONG
137 Either the total length of \fIpathname\fP is greater than
138 \fBPATH_MAX\fP, or an individual filename component has a length
139 greater than \fBNAME_MAX\fP.
140 In the GNU system, there is no imposed
141 limit on overall filename length, but some filesystems may place
142 limits on the length of a component.
143 .TP
144 .B ENOENT
145 A directory component in \fIpathname\fP does not exist or is a
146 dangling symbolic link.
147 .TP
148 .B ENOSPC
149 The directory or filesystem has no room for the new file.
150 .TP
151 .B ENOTDIR
152 A component used as a directory in \fIpathname\fP is not, in fact, a
153 directory.
154 .TP
155 .B ENOTDIR
156 .RB ( mkfifoat ())
157 .I pathname
158 is a relative pathname and
159 .I dirfd
160 is a file descriptor referring to a file other than a directory.
161 .TP
162 .B EROFS
163 \fIpathname\fP refers to a read-only filesystem.
164 .SH VERSIONS
165 .BR mkfifoat ()
166 was added to glibc in version 2.4.
167 It is implemented using
168 .BR mknodat (2),
169 available on Linux since kernel 2.6.16.
170 .SH ATTRIBUTES
171 For an explanation of the terms used in this section, see
172 .BR attributes (7).
173 .ad l
174 .nh
175 .TS
176 allbox;
177 lbx lb lb
178 l l l.
179 Interface Attribute Value
180 T{
181 .BR mkfifo (),
182 .BR mkfifoat ()
183 T} Thread safety MT-Safe
184 .TE
185 .hy
186 .ad
187 .sp 1
188 .SH STANDARDS
189 .BR mkfifo ():
190 POSIX.1-2001, POSIX.1-2008.
191 .PP
192 .BR mkfifoat ():
193 POSIX.1-2008.
194 .SH SEE ALSO
195 .BR mkfifo (1),
196 .BR close (2),
197 .BR open (2),
198 .BR read (2),
199 .BR stat (2),
200 .BR umask (2),
201 .BR write (2),
202 .BR fifo (7)