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
http://www.opengroup.org/bookstore/.
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 SunOS 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.
This notice shall appear on any product containing this material.
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.
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.
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]
Copyright 1989 AT&T
Copyright (c) 2001, The IEEE and The Open Group. All Rights Reserved.
Copyright (c) 2002, Sun Microsystems, Inc. All Rights Reserved.
Copyright (c) 2014, Joyent, Inc.
#include <sys/types.h> #include <sys/stat.h> int mkfifo(const char *path, mode_t mode);
int mkfifoat(int fd, const char *path, mode_t mode);
If path names a symbolic link, mkfifo() and mkfifoat() fail and set errno to EEXIST.
The FIFO's user ID is set to the process's effective user ID. The FIFO's group ID is set to the group ID of the parent directory or to the effective group ID of the process.
The mkfifoat() function is equivalent to mkfifo(); however, if path is a relative path, then it is resolved start at the directory represented by fd. fd may be set to the special value of AT_FDCWD which indicates that the current working directory should be used to start resolving path.
The mkfifo() function calls mknod(2) to create the file. The mkfifoat() function calls mknodat(2) to create the file.
Upon successful completion, mkfifo() and mkfifoat() mark for update the st_atime, st_ctime, and st_mtime fields of the file. Also, the st_ctime and st_mtime fields of the directory that contains the new entry are marked for update.
A component of the path prefix denies search permission, or write permission is denied on the parent directory of the FIFO to be created.
The named file already exists.
A loop exists in symbolic links encountered during resolution of the path argument.
The length of the path argument exceeds {PATH_MAX} or a pathname component is longer than {NAME_MAX}.
A component of the path prefix specified by path does not name an existing directory or path is an empty string.
The directory that would contain the new file cannot be extended or the file system is out of file-allocation resources.
A component of the path prefix is not a directory. For mkfifoat(), path is a relative path and fd is a valid file descriptor which is not a directory.
The named file resides on a read-only file system.
The mkfifoat() function will fail if: EBADF
The path argument is a relative path and fd is not a valid file descriptor or the value AT_FDCWD.
The mkfifo() function may fail if: ELOOP
Too many symbolic links were encountered in resolving path.
The length of the path argument exceeds {PATH_MAX} or a pathname component is longer than {NAME_MAX}.
The following example demonstrates how to create a FIFO file named /home/cnd/mod_done with read and write permissions for the owner and read permissions for the group and others.
#include <sys/types.h> #include <sys/stat.h> int status; ... status = mkfifo("/home/cnd/mod_done", S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH);
ATTRIBUTE TYPE ATTRIBUTE VALUE |
Interface Stability Standard |
MT-Level MT-Safe |