poll.2: Remove <signal.h>
[man-pages.git] / man3 / mkfifo.3
blobe98c3488e2b585c2830e7aed537dc23ac5bdea20
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.
114 .SH RETURN VALUE
115 On success
116 .BR mkfifo ()
118 .BR mkfifoat ()
119 return 0.
120 On error, \-1 is returned and
121 .I errno
122 is set to indicate the error.
123 .SH ERRORS
125 .B EACCES
126 One of the directories in \fIpathname\fP did not allow search
127 (execute) permission.
129 .B EDQUOT
130 The user's quota of disk blocks or inodes on the filesystem has been
131 exhausted.
133 .B EEXIST
134 \fIpathname\fP already exists.
135 This includes the case where
136 .I pathname
137 is a symbolic link, dangling or not.
139 .B ENAMETOOLONG
140 Either the total length of \fIpathname\fP is greater than
141 \fBPATH_MAX\fP, or an individual filename component has a length
142 greater than \fBNAME_MAX\fP.
143 In the GNU system, there is no imposed
144 limit on overall filename length, but some filesystems may place
145 limits on the length of a component.
147 .B ENOENT
148 A directory component in \fIpathname\fP does not exist or is a
149 dangling symbolic link.
151 .B ENOSPC
152 The directory or filesystem has no room for the new file.
154 .B ENOTDIR
155 A component used as a directory in \fIpathname\fP is not, in fact, a
156 directory.
158 .B EROFS
159 \fIpathname\fP refers to a read-only filesystem.
161 The following additional errors can occur for
162 .BR mkfifoat ():
164 .B EBADF
165 .I dirfd
166 is not a valid file descriptor.
168 .B ENOTDIR
169 .I pathname
170 is a relative path and
171 .I dirfd
172 is a file descriptor referring to a file other than a directory.
173 .SH VERSIONS
174 .BR mkfifoat ()
175 was added to glibc in version 2.4.
176 It is implemented using
177 .BR mknodat (2),
178 available on Linux since kernel 2.6.16.
179 .SH ATTRIBUTES
180 For an explanation of the terms used in this section, see
181 .BR attributes (7).
182 .ad l
185 allbox;
186 lbx lb lb
187 l l l.
188 Interface       Attribute       Value
190 .BR mkfifo (),
191 .BR mkfifoat ()
192 T}      Thread safety   MT-Safe
196 .sp 1
197 .SH CONFORMING TO
198 .BR mkfifo ():
199 POSIX.1-2001, POSIX.1-2008.
201 .BR mkfifoat ():
202 POSIX.1-2008.
203 .SH SEE ALSO
204 .BR mkfifo (1),
205 .BR close (2),
206 .BR open (2),
207 .BR read (2),
208 .BR stat (2),
209 .BR umask (2),
210 .BR write (2),
211 .BR fifo (7)