OSDN Git Service

Update README
[linuxjm/LDP_man-pages.git] / original / 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 .\" %%%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 2014-03-24 "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 .sp
36 .BI "int mkfifo(const char *" pathname ", mode_t " mode );
37 .sp
38 .BR "#include <fcntl.h>           " "/* Definition of AT_* constants */"
39 .B #include <sys/stat.h>
40 .sp
41 .BI "int mkfifoat(int " dirfd ", const char *" pathname ", mode_t " mode );
42 .fi
43 .sp
44 .in -4n
45 Feature Test Macro Requirements for glibc (see
46 .BR feature_test_macros (7)):
47 .in
48 .sp
49 .BR mkfifoat ():
50 .PD 0
51 .ad l
52 .RS 4
53 .TP 4
54 Since glibc 2.10:
55 _XOPEN_SOURCE\ >=\ 700 || _POSIX_C_SOURCE\ >=\ 200809L
56 .TP
57 Before glibc 2.10:
58 _ATFILE_SOURCE
59 .RE
60 .ad
61 .PD
62 .SH DESCRIPTION
63 .BR mkfifo ()
64 makes a FIFO special file with name \fIpathname\fP.
65 \fImode\fP specifies the FIFO's permissions.
66 It is modified by the
67 process's \fBumask\fP in the usual way: the permissions of the created
68 file are \fB(\fP\fImode\fP\fB & ~umask)\fP.
69 .PP
70 A FIFO special file is similar to a pipe, except that it is created
71 in a different way.
72 Instead of being an anonymous communications
73 channel, a FIFO special file is entered into the filesystem by
74 calling
75 .BR mkfifo ().
76 .PP
77 Once you have created a FIFO special file in this way, any process can
78 open it for reading or writing, in the same way as an ordinary file.
79 However, it has to be open at both ends simultaneously before you can
80 proceed to do any input or output operations on it.
81 Opening a FIFO for reading normally blocks until some
82 other process opens the same FIFO for writing, and vice versa.
83 See
84 .BR fifo (7)
85 for nonblocking handling of FIFO special files.
86 .SS mkfifoat()
87 The
88 .BR mkfifoat ()
89 function operates in exactly the same way as
90 .BR mkfifo (),
91 except for the differences described here.
92
93 If the pathname given in
94 .I pathname
95 is relative, then it is interpreted relative to the directory
96 referred to by the file descriptor
97 .I dirfd
98 (rather than relative to the current working directory of
99 the calling process, as is done by
100 .BR mkfifo ()
101 for a relative pathname).
102
103 If
104 .I pathname
105 is relative and
106 .I dirfd
107 is the special value
108 .BR AT_FDCWD ,
109 then
110 .I pathname
111 is interpreted relative to the current working
112 directory of the calling process (like
113 .BR mkfifo ()).
114
115 If
116 .I pathname
117 is absolute, then
118 .I dirfd
119 is ignored.
120 .SH RETURN VALUE
121 On success
122 .BR mkfifo ()
123 and
124 .BR mkfifoat ()
125 return 0.
126 In the case of an error, \-1 is returned (in which case, \fIerrno\fP
127 is set appropriately).
128 .SH ERRORS
129 .TP
130 .B EACCES
131 One of the directories in \fIpathname\fP did not allow search
132 (execute) permission.
133 .TP
134 .B EDQUOT
135 The user's quota of disk blocks or inodes on the filesystem has been
136 exhausted.
137 .TP
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.
143 .TP
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.
151 .TP
152 .B ENOENT
153 A directory component in \fIpathname\fP does not exist or is a
154 dangling symbolic link.
155 .TP
156 .B ENOSPC
157 The directory or filesystem has no room for the new file.
158 .TP
159 .B ENOTDIR
160 A component used as a directory in \fIpathname\fP is not, in fact, a
161 directory.
162 .TP
163 .B EROFS
164 \fIpathname\fP refers to a read-only filesystem.
165 .PP
166 The following additional errors can occur for
167 .BR mkfifoat ():
168 .TP
169 .B EBADF
170 .I dirfd
171 is not a valid file descriptor.
172 .TP
173 .B ENOTDIR
174 .I pathname
175 is a relative path and
176 .I dirfd
177 is a file descriptor referring to a file other than a directory.
178 .SH VERSIONS
179 .BR mkfifoat ()
180 was added to glibc in version 2.4.
181 It is implemented using
182 .BR mknodat (2),
183 available on Linux since kernel 2.6.16.
184 .SH ATTRIBUTES
185 .SS Multithreading (see pthreads(7))
186 The
187 .BR mkfifo ()
188 and
189 .BR mkfifoat ()
190 functions are thread-safe.
191 .SH CONFORMING TO
192 .BR mkfifo ():
193 POSIX.1-2001, POSIX.1-2008.
194
195 .BR mkfifoat ():
196 POSIX.1-2008.
197 .SH SEE ALSO
198 .BR mkfifo (1),
199 .BR close (2),
200 .BR open (2),
201 .BR read (2),
202 .BR stat (2),
203 .BR umask (2),
204 .BR write (2),
205 .BR fifo (7)
206 .SH COLOPHON
207 This page is part of release 3.79 of the Linux
208 .I man-pages
209 project.
210 A description of the project,
211 information about reporting bugs,
212 and the latest version of this page,
213 can be found at
214 \%http://www.kernel.org/doc/man\-pages/.