1mkfifo(3C) Standard C Library Functions mkfifo(3C)
2
3
4
6 mkfifo - make a FIFO special file
7
9 #include <sys/types.h>
10 #include <sys/stat.h>
11
12 int mkfifo(const char *path, mode_t mode);
13
14
16 The mkfifo() function creates a new FIFO special file named by the
17 pathname pointed to by path. The file permission bits of the new FIFO
18 are initialized from mode. The file permission bits of the mode argu‐
19 ment are modified by the process's file creation mask (see umask(2)).
20 Bits other than the file permission bits in mode are ignored.
21
22
23 If path names a symbolic link, mkfifo() fails and sets errno to EEXIST.
24
25
26 The FIFO's user ID is set to the process's effective user ID. The
27 FIFO's group ID is set to the group ID of the parent directory or to
28 the effective group ID of the process.
29
30
31 The mkfifo() function calls mknod(2) to create the file.
32
33
34 Upon successful completion, mkfifo() marks for update the st_atime,
35 st_ctime, and st_mtime fields of the file. Also, the st_ctime and
36 st_mtime fields of the directory that contains the new entry are marked
37 for update.
38
40 Upon successful completion, 0 is returned. Otherwise, −1 is returned
41 and errno is set to indicate the error.
42
44 The mkfifo() function will fail if:
45
46 EACCES A component of the path prefix denies search permis‐
47 sion, or write permission is denied on the parent
48 directory of the FIFO to be created.
49
50
51 EEXIST The named file already exists.
52
53
54 ELOOP A loop exists in symbolic links encountered during res‐
55 olution of the path argument.
56
57
58 ENAMETOOLONG The length of the path argument exceeds {PATH_MAX} or a
59 pathname component is longer than {NAME_MAX}.
60
61
62 ENOENT A component of the path prefix specified by path does
63 not name an existing directory or path is an empty
64 string.
65
66
67 ENOSPC The directory that would contain the new file cannot be
68 extended or the file system is out of file-allocation
69 resources.
70
71
72 ENOTDIR A component of the path prefix is not a directory.
73
74
75 EROFS The named file resides on a read-only file system.
76
77
78
79 The mkfifo() function may fail if:
80
81 ELOOP Too many symbolic links were encountered in resolving
82 path.
83
84
85 ENAMETOOLONG The length of the path argument exceeds {PATH_MAX} or a
86 pathname component is longer than {NAME_MAX}.
87
88
90 Example 1 Create a FIFO File
91
92
93 The following example demonstrates how to create a FIFO file named
94 /home/cnd/mod_done with read and write permissions for the owner and
95 read permissions for the group and others.
96
97
98 #include sys/types.h>
99 #include sys/stat.h>
100 int status;
101 ...
102 status = mkfifo("/home/cnd/mod_done", S_IWUSR | S_IRUSR |
103 S_IRGRP | S_IROTH);
104
105
107 See attributes(5) for descriptions of the following attributes:
108
109
110
111
112 ┌─────────────────────────────┬─────────────────────────────┐
113 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
114 ├─────────────────────────────┼─────────────────────────────┤
115 │Interface Stability │Standard │
116 ├─────────────────────────────┼─────────────────────────────┤
117 │MT-Level │MT-Safe │
118 └─────────────────────────────┴─────────────────────────────┘
119
121 mkdir(1), chmod(2), exec(2), mknod(2), umask(2), stat.h(3HEAD),
122 ufs(7FS), attributes(5), standards(5)
123
124
125
126SunOS 5.11 24 Apr 2002 mkfifo(3C)