]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/mkfifo.3
fanotify_init.2, fanotify.7: Document FAN_REPORT_TID
[thirdparty/man-pages.git] / man3 / mkfifo.3
CommitLineData
fea681da 1.\" This manpage is Copyright (C) 1995 James R. Van Zandt <jrv@vanzandt.mv.com>
464bbf04 2.\" and Copyright (C) 2006, 2014 Michael Kerrisk
fea681da 3.\"
93015253 4.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
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.
c13182ef 13.\"
fea681da
MK
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.
c13182ef 21.\"
fea681da
MK
22.\" Formatted or processed versions of this manual, if unaccompanied by
23.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 24.\" %%%LICENSE_END
fea681da
MK
25.\"
26.\" changed section from 2 to 3, aeb, 950919
27.\"
4b8c67d9 28.TH MKFIFO 3 2017-09-15 "GNU" "Linux Programmer's Manual"
fea681da 29.SH NAME
464bbf04 30mkfifo, mkfifoat \- make a FIFO special file (a named pipe)
fea681da
MK
31.SH SYNOPSIS
32.nf
33.B #include <sys/types.h>
34.B #include <sys/stat.h>
68e4db0a 35.PP
fea681da 36.BI "int mkfifo(const char *" pathname ", mode_t " mode );
f90f031e 37
464bbf04
MK
38.BR "#include <fcntl.h> " "/* Definition of AT_* constants */"
39.B #include <sys/stat.h>
68e4db0a 40.PP
464bbf04 41.BI "int mkfifoat(int " dirfd ", const char *" pathname ", mode_t " mode );
fea681da 42.fi
68e4db0a 43.PP
464bbf04
MK
44.in -4n
45Feature Test Macro Requirements for glibc (see
46.BR feature_test_macros (7)):
47.in
68e4db0a 48.PP
464bbf04
MK
49.BR mkfifoat ():
50.PD 0
51.ad l
52.RS 4
53.TP 4
54Since glibc 2.10:
b0da7b8b 55_POSIX_C_SOURCE\ >=\ 200809L
464bbf04
MK
56.TP
57Before glibc 2.10:
58_ATFILE_SOURCE
59.RE
60.ad
61.PD
fea681da 62.SH DESCRIPTION
60a90ecd
MK
63.BR mkfifo ()
64makes a FIFO special file with name \fIpathname\fP.
c13182ef
MK
65\fImode\fP specifies the FIFO's permissions.
66It is modified by the
fea681da
MK
67process's \fBumask\fP in the usual way: the permissions of the created
68file are \fB(\fP\fImode\fP\fB & ~umask)\fP.
69.PP
70A FIFO special file is similar to a pipe, except that it is created
c13182ef
MK
71in a different way.
72Instead of being an anonymous communications
9ee4a2b6 73channel, a FIFO special file is entered into the filesystem by
60a90ecd
MK
74calling
75.BR mkfifo ().
fea681da
MK
76.PP
77Once you have created a FIFO special file in this way, any process can
78open it for reading or writing, in the same way as an ordinary file.
79However, it has to be open at both ends simultaneously before you can
c13182ef
MK
80proceed to do any input or output operations on it.
81Opening a FIFO for reading normally blocks until some
82other process opens the same FIFO for writing, and vice versa.
83See
af5b2ef2 84.BR fifo (7)
ff40dbb3 85for nonblocking handling of FIFO special files.
464bbf04
MK
86.SS mkfifoat()
87The
88.BR mkfifoat ()
89function operates in exactly the same way as
cadd38ba 90.BR mkfifo (),
464bbf04 91except for the differences described here.
847e0d88 92.PP
464bbf04
MK
93If the pathname given in
94.I pathname
95is relative, then it is interpreted relative to the directory
96referred to by the file descriptor
97.I dirfd
98(rather than relative to the current working directory of
99the calling process, as is done by
cadd38ba 100.BR mkfifo ()
464bbf04 101for a relative pathname).
847e0d88 102.PP
464bbf04
MK
103If
104.I pathname
105is relative and
106.I dirfd
107is the special value
108.BR AT_FDCWD ,
109then
110.I pathname
111is interpreted relative to the current working
112directory of the calling process (like
cadd38ba 113.BR mkfifo ()).
847e0d88 114.PP
464bbf04
MK
115If
116.I pathname
117is absolute, then
118.I dirfd
119is ignored.
47297adb 120.SH RETURN VALUE
d9c1ae64
MK
121On success
122.BR mkfifo ()
464bbf04
MK
123and
124.BR mkfifoat ()
125return 0.
f262c004 126In the case of an error, \-1 is returned (in which case, \fIerrno\fP
fea681da
MK
127is set appropriately).
128.SH ERRORS
129.TP
130.B EACCES
131One of the directories in \fIpathname\fP did not allow search
132(execute) permission.
133.TP
a1f01685 134.B EDQUOT
9ee4a2b6 135The user's quota of disk blocks or inodes on the filesystem has been
a1f01685
MH
136exhausted.
137.TP
fea681da
MK
138.B EEXIST
139\fIpathname\fP already exists.
9d6299e8
MK
140This includes the case where
141.I pathname
142is a symbolic link, dangling or not.
fea681da
MK
143.TP
144.B ENAMETOOLONG
145Either the total length of \fIpathname\fP is greater than
2c5f1089 146\fBPATH_MAX\fP, or an individual filename component has a length
c13182ef
MK
147greater than \fBNAME_MAX\fP.
148In the GNU system, there is no imposed
9ee4a2b6 149limit on overall filename length, but some filesystems may place
fea681da
MK
150limits on the length of a component.
151.TP
152.B ENOENT
153A directory component in \fIpathname\fP does not exist or is a
154dangling symbolic link.
155.TP
156.B ENOSPC
9ee4a2b6 157The directory or filesystem has no room for the new file.
fea681da
MK
158.TP
159.B ENOTDIR
160A component used as a directory in \fIpathname\fP is not, in fact, a
161directory.
162.TP
163.B EROFS
9ee4a2b6 164\fIpathname\fP refers to a read-only filesystem.
464bbf04
MK
165.PP
166The following additional errors can occur for
167.BR mkfifoat ():
168.TP
169.B EBADF
170.I dirfd
171is not a valid file descriptor.
172.TP
173.B ENOTDIR
174.I pathname
175is a relative path and
176.I dirfd
177is a file descriptor referring to a file other than a directory.
178.SH VERSIONS
179.BR mkfifoat ()
180was added to glibc in version 2.4.
181It is implemented using
94810bd7 182.BR mknodat (2),
464bbf04 183available on Linux since kernel 2.6.16.
2b9e0a13 184.SH ATTRIBUTES
f1d8eed6
PH
185For an explanation of the terms used in this section, see
186.BR attributes (7).
187.TS
188allbox;
189lbw20 lb lb
190l l l.
191Interface Attribute Value
192T{
193.BR mkfifo (),
2b9e0a13 194.BR mkfifoat ()
f1d8eed6
PH
195T} Thread safety MT-Safe
196.TE
47297adb 197.SH CONFORMING TO
464bbf04 198.BR mkfifo ():
64b7542e 199POSIX.1-2001, POSIX.1-2008.
847e0d88 200.PP
464bbf04
MK
201.BR mkfifoat ():
202POSIX.1-2008.
47297adb 203.SH SEE ALSO
fea681da
MK
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),
af5b2ef2 211.BR fifo (7)