Merge commit '9276b3991ba20d5a5660887ba81b0bc7bed25a0c'
[unleashed.git] / share / man / man3c / mkfifo.3c
blob5923982c224526ae5329c2551172ae59cf8ccf6a
1 '\" te
2 .\" Copyright (c) 2002, Sun Microsystems, Inc.  All Rights Reserved.
3 .\" Copyright (c) 2014, Joyent, Inc.
4 .\" Copyright 1989 AT&T
5 .\" Portions Copyright (c) 2001, the Institute of Electrical and Electronics Engineers, Inc. and The Open Group. All Rights Reserved.
6 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
7 .\" http://www.opengroup.org/bookstore/.
8 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
9 .\"  This notice shall appear on any product containing this material.
10 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
11 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
12 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
13 .TH MKFIFO 3C "Apr 24, 2002"
14 .SH NAME
15 mkfifo, mkfifoat \- make a FIFO special file
16 .SH SYNOPSIS
17 .LP
18 .nf
19 #include <sys/types.h>
20 #include <sys/stat.h>
22 \fBint\fR \fBmkfifo\fR(\fBconst char *\fR\fIpath\fR, \fBmode_t\fR \fImode\fR);
23 .fi
24 .LP
25 .nf
26 \fBint\fR \fBmkfifoat\fR(\fBint\fR \fIfd\fR, \fBconst char *\fR\fIpath\fR, \fBmode_t\fR \fImode\fR);
27 .fi
29 .SH DESCRIPTION
30 .LP
31 The \fBmkfifo()\fR and \fBmkfifoat()\fR functions create a new FIFO special file
32 named by the pathname pointed to by \fIpath\fR.  The file permission bits of the
33 new FIFO are initialized from \fImode\fR.  The file permission bits of the
34 \fImode\fR argument are modified by the process's file creation mask (see
35 \fBumask\fR(2)).  Bits other than the file permission bits in \fImode\fR are
36 ignored.
37 .sp
38 .LP
39 If \fIpath\fR names a symbolic link, \fBmkfifo()\fR and \fBmkfifoat()\fR fail
40 and set \fBerrno\fR to \fBEEXIST\fR.
41 .sp
42 .LP
43 The FIFO's user ID is set to the process's effective user ID. The FIFO's group
44 ID is set to the group ID of the parent directory or to the effective group ID
45 of the process.
46 .sp
47 .LP
48 The \fBmkfifoat()\fR function is equivalent to \fBmkfifo()\fR; however, if
49 \fIpath\fR is a relative path, then it is resolved start at the directory
50 represented by \fIfd\fR. \fIfd\fR may be set to the special value of
51 \fBAT_FDCWD\fR which indicates that the current working directory should be used
52 to start resolving \fIpath\fR.
53 .sp
54 .LP
55 The \fBmkfifo()\fR function calls \fBmknod\fR(2) to create the file. The
56 \fBmkfifoat()\fR function calls \fBmknodat\fR(2) to create the file.
57 .sp
58 .LP
59 Upon successful completion, \fBmkfifo()\fR and \fBmkfifoat()\fR mark for update
60 the \fBst_atime\fR, \fBst_ctime\fR, and \fBst_mtime\fR fields of the file. Also,
61 the \fBst_ctime\fR and \fBst_mtime\fR fields of the directory that contains the
62 new entry are marked for update.
63 .SH RETURN VALUES
64 .LP
65 Upon successful completion, \fB0\fR is returned.  Otherwise, \fB\(mi1\fR is
66 returned and \fBerrno\fR is set to indicate the error.
67 .SH ERRORS
68 .LP
69 The \fBmkfifo()\fR and \fBmkfifoat()\fR functions will fail if:
70 .sp
71 .ne 2
72 .na
73 \fB\fBEACCES\fR\fR
74 .ad
75 .RS 16n
76 A component of the path prefix denies search permission, or write permission is
77 denied on the parent directory of the FIFO to be created.
78 .RE
80 .sp
81 .ne 2
82 .na
83 \fB\fBEEXIST\fR\fR
84 .ad
85 .RS 16n
86 The named file already exists.
87 .RE
89 .sp
90 .ne 2
91 .na
92 \fB\fBELOOP\fR\fR
93 .ad
94 .RS 16n
95 A loop exists in symbolic links encountered during resolution of the \fIpath\fR
96 argument.
97 .RE
99 .sp
100 .ne 2
102 \fB\fBENAMETOOLONG\fR\fR
104 .RS 16n
105 The length of the \fIpath\fR argument exceeds {\fBPATH_MAX\fR} or a pathname
106 component is longer than {\fBNAME_MAX\fR}.
110 .ne 2
112 \fB\fBENOENT\fR\fR
114 .RS 16n
115 A component of the path prefix specified by \fIpath\fR does not name an
116 existing directory or \fIpath\fR is an empty string.
120 .ne 2
122 \fB\fBENOSPC\fR\fR
124 .RS 16n
125 The directory that would contain the new file cannot be extended or the file
126 system is out of file-allocation resources.
130 .ne 2
132 \fB\fBENOTDIR\fR\fR
134 .RS 16n
135 A component of the path prefix is not a directory. For \fBmkfifoat()\fR,
136 \fIpath\fR is a relative path and \fIfd\fR is a valid file descriptor which is
137 not a directory.
141 .ne 2
143 \fB\fBEROFS\fR\fR
145 .RS 16n
146 The named file resides on a read-only file system.
151 The \fBmkfifoat()\fR function will fail if:
153 .ne 2
155 .B EBADF
157 .RS 16n
158 The \fIpath\fR argument is a relative path and \fIfd\fR is not a valid file
159 descriptor or the value \fBAT_FDCWD\fR.
164 The \fBmkfifo()\fR function may fail if:
166 .ne 2
168 \fB\fBELOOP\fR\fR
170 .RS 16n
171 Too many symbolic links were encountered in resolving \fIpath\fR.
175 .ne 2
177 \fB\fBENAMETOOLONG\fR\fR
179 .RS 16n
180 The length of the \fIpath\fR argument exceeds {\fBPATH_MAX\fR} or a pathname
181 component is longer than {\fBNAME_MAX\fR}.
184 .SH EXAMPLES
186 \fBExample 1 \fRCreate a FIFO File
189 The following example demonstrates how to create a FIFO file named
190 \fB/home/cnd/mod_done\fR with read and write permissions for the owner and read
191 permissions for the group and others.
194 .in +2
196 #include sys/types.h>
197 #include sys/stat.h>
198 int status;
199 \&...
200 status = mkfifo("/home/cnd/mod_done", S_IWUSR | S_IRUSR |
201         S_IRGRP | S_IROTH);
203 .in -2
205 .SH ATTRIBUTES
207 See \fBattributes\fR(5) for descriptions of the following attributes:
212 box;
213 c | c
214 l | l .
215 ATTRIBUTE TYPE  ATTRIBUTE VALUE
217 Interface Stability     Standard
219 MT-Level        MT-Safe
222 .SH SEE ALSO
224 \fBmkdir\fR(1), \fBchmod\fR(2), \fBexec\fR(2), \fBmknod\fR(2), \fBumask\fR(2),
225 \fBstat.h\fR(3HEAD), \fBufs\fR(7FS), \fBattributes\fR(5), \fBstandards\fR(5)