1MKFIFO(P) POSIX Programmer's Manual MKFIFO(P)
2
3
4
6 mkfifo - make a FIFO special file
7
9 #include <sys/stat.h>
10
11 int mkfifo(const char *path, mode_t mode);
12
13
15 The mkfifo() function shall create a new FIFO special file named by the
16 pathname pointed to by path. The file permission bits of the new FIFO
17 shall be initialized from mode. The file permission bits of the mode
18 argument shall be modified by the process' file creation mask.
19
20 When bits in mode other than the file permission bits are set, the
21 effect is implementation-defined.
22
23 If path names a symbolic link, mkfifo() shall fail and set errno to
24 [EEXIST].
25
26 The FIFO's user ID shall be set to the process' effective user ID. The
27 FIFO's group ID shall be set to the group ID of the parent directory or
28 to the effective group ID of the process. Implementations shall provide
29 a way to initialize the FIFO's group ID to the group ID of the parent
30 directory. Implementations may, but need not, provide an implementa‐
31 tion-defined way to initialize the FIFO's group ID to the effective
32 group ID of the calling process.
33
34 Upon successful completion, mkfifo() shall mark for update the
35 st_atime, st_ctime, and st_mtime fields of the file. Also, the st_ctime
36 and st_mtime fields of the directory that contains the new entry shall
37 be marked for update.
38
40 Upon successful completion, 0 shall be returned. Otherwise, -1 shall be
41 returned, no FIFO shall be created, and errno shall be set to indicate
42 the error.
43
45 The mkfifo() function shall fail if:
46
47 EACCES A component of the path prefix denies search permission, or
48 write permission is denied on the parent directory of the FIFO
49 to be created.
50
51 EEXIST The named file already exists.
52
53 ELOOP A loop exists in symbolic links encountered during resolution of
54 the path argument.
55
56 ENAMETOOLONG
57 The length of the path argument exceeds {PATH_MAX} or a pathname
58 component is longer than {NAME_MAX}.
59
60 ENOENT A component of the path prefix specified by path does not name
61 an existing directory or path is an empty string.
62
63 ENOSPC The directory that would contain the new file cannot be extended
64 or the file system is out of file-allocation resources.
65
66 ENOTDIR
67 A component of the path prefix is not a directory.
68
69 EROFS The named file resides on a read-only file system.
70
71
72 The mkfifo() function may fail if:
73
74 ELOOP More than {SYMLOOP_MAX} symbolic links were encountered during
75 resolution of the path argument.
76
77 ENAMETOOLONG
78 As a result of encountering a symbolic link in resolution of the
79 path argument, the length of the substituted pathname string
80 exceeded {PATH_MAX}.
81
82
83 The following sections are informative.
84
86 Creating a FIFO File
87 The following example shows how to create a FIFO file named
88 /home/cnd/mod_done, with read/write permissions for owner, and with
89 read permissions for group and others.
90
91
92 #include <sys/types.h>
93 #include <sys/stat.h>
94
95
96 int status;
97 ...
98 status = mkfifo("/home/cnd/mod_done", S_IWUSR | S_IRUSR |
99 S_IRGRP | S_IROTH);
100
102 None.
103
105 The syntax of this function is intended to maintain compatibility with
106 historical implementations of mknod(). The latter function was included
107 in the 1984 /usr/group standard but only for use in creating FIFO spe‐
108 cial files. The mknod() function was originally excluded from the
109 POSIX.1-1988 standard as implementation-defined and replaced by mkdir()
110 and mkfifo(). The mknod() function is now included for alignment with
111 the Single UNIX Specification.
112
113 The POSIX.1-1990 standard required that the group ID of a newly created
114 FIFO be set to the group ID of its parent directory or to the effective
115 group ID of the creating process. FIPS 151-2 required that implementa‐
116 tions provide a way to have the group ID be set to the group ID of the
117 containing directory, but did not prohibit implementations also sup‐
118 porting a way to set the group ID to the effective group ID of the cre‐
119 ating process. Conforming applications should not assume which group ID
120 will be used. If it matters, an application can use chown() to set the
121 group ID after the FIFO is created, or determine under what conditions
122 the implementation will set the desired group ID.
123
125 None.
126
128 umask() , the Base Definitions volume of IEEE Std 1003.1-2001,
129 <sys/stat.h>, <sys/types.h>
130
132 Portions of this text are reprinted and reproduced in electronic form
133 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
134 -- Portable Operating System Interface (POSIX), The Open Group Base
135 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
136 Electrical and Electronics Engineers, Inc and The Open Group. In the
137 event of any discrepancy between this version and the original IEEE and
138 The Open Group Standard, the original IEEE and The Open Group Standard
139 is the referee document. The original Standard can be obtained online
140 at http://www.opengroup.org/unix/online.html .
141
142
143
144IEEE/The Open Group 2003 MKFIFO(P)