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