Blame man3/mkfifo.3

Packit 7cfc04
.\" This manpage is Copyright (C) 1995 James R. Van Zandt <jrv@vanzandt.mv.com>
Packit 7cfc04
.\" and Copyright (C) 2006, 2014 Michael Kerrisk
Packit 7cfc04
.\"
Packit 7cfc04
.\" %%%LICENSE_START(VERBATIM)
Packit 7cfc04
.\" Permission is granted to make and distribute verbatim copies of this
Packit 7cfc04
.\" manual provided the copyright notice and this permission notice are
Packit 7cfc04
.\" preserved on all copies.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Permission is granted to copy and distribute modified versions of this
Packit 7cfc04
.\" manual under the conditions for verbatim copying, provided that the
Packit 7cfc04
.\" entire resulting derived work is distributed under the terms of a
Packit 7cfc04
.\" permission notice identical to this one.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Since the Linux kernel and libraries are constantly changing, this
Packit 7cfc04
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
Packit 7cfc04
.\" responsibility for errors or omissions, or for damages resulting from
Packit 7cfc04
.\" the use of the information contained herein.  The author(s) may not
Packit 7cfc04
.\" have taken the same level of care in the production of this manual,
Packit 7cfc04
.\" which is licensed free of charge, as they might when working
Packit 7cfc04
.\" professionally.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Formatted or processed versions of this manual, if unaccompanied by
Packit 7cfc04
.\" the source, must acknowledge the copyright and authors of this work.
Packit 7cfc04
.\" %%%LICENSE_END
Packit 7cfc04
.\"
Packit 7cfc04
.\" changed section from 2 to 3, aeb, 950919
Packit 7cfc04
.\"
Packit 7cfc04
.TH MKFIFO 3 2017-09-15 "GNU" "Linux Programmer's Manual"
Packit 7cfc04
.SH NAME
Packit 7cfc04
mkfifo, mkfifoat \- make a FIFO special file (a named pipe)
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.nf
Packit 7cfc04
.B #include <sys/types.h>
Packit 7cfc04
.B #include <sys/stat.h>
Packit 7cfc04
.PP
Packit 7cfc04
.BI "int mkfifo(const char *" pathname ", mode_t " mode );
Packit 7cfc04
Packit 7cfc04
.BR "#include <fcntl.h>           " "/* Definition of AT_* constants */"
Packit 7cfc04
.B #include <sys/stat.h>
Packit 7cfc04
.PP
Packit 7cfc04
.BI "int mkfifoat(int " dirfd ", const char *" pathname ", mode_t " mode );
Packit 7cfc04
.fi
Packit 7cfc04
.PP
Packit 7cfc04
.in -4n
Packit 7cfc04
Feature Test Macro Requirements for glibc (see
Packit 7cfc04
.BR feature_test_macros (7)):
Packit 7cfc04
.in
Packit 7cfc04
.PP
Packit 7cfc04
.BR mkfifoat ():
Packit 7cfc04
.PD 0
Packit 7cfc04
.ad l
Packit 7cfc04
.RS 4
Packit 7cfc04
.TP 4
Packit 7cfc04
Since glibc 2.10:
Packit 7cfc04
_POSIX_C_SOURCE\ >=\ 200809L
Packit 7cfc04
.TP
Packit 7cfc04
Before glibc 2.10:
Packit 7cfc04
_ATFILE_SOURCE
Packit 7cfc04
.RE
Packit 7cfc04
.ad
Packit 7cfc04
.PD
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
.BR mkfifo ()
Packit 7cfc04
makes a FIFO special file with name \fIpathname\fP.
Packit 7cfc04
\fImode\fP specifies the FIFO's permissions.
Packit 7cfc04
It is modified by the
Packit 7cfc04
process's \fBumask\fP in the usual way: the permissions of the created
Packit 7cfc04
file are \fB(\fP\fImode\fP\fB & ~umask)\fP.
Packit 7cfc04
.PP
Packit 7cfc04
A FIFO special file is similar to a pipe, except that it is created
Packit 7cfc04
in a different way.
Packit 7cfc04
Instead of being an anonymous communications
Packit 7cfc04
channel, a FIFO special file is entered into the filesystem by
Packit 7cfc04
calling
Packit 7cfc04
.BR mkfifo ().
Packit 7cfc04
.PP
Packit 7cfc04
Once you have created a FIFO special file in this way, any process can
Packit 7cfc04
open it for reading or writing, in the same way as an ordinary file.
Packit 7cfc04
However, it has to be open at both ends simultaneously before you can
Packit 7cfc04
proceed to do any input or output operations on it.
Packit 7cfc04
Opening a FIFO for reading normally blocks until some
Packit 7cfc04
other process opens the same FIFO for writing, and vice versa.
Packit 7cfc04
See
Packit 7cfc04
.BR fifo (7)
Packit 7cfc04
for nonblocking handling of FIFO special files.
Packit 7cfc04
.SS mkfifoat()
Packit 7cfc04
The
Packit 7cfc04
.BR mkfifoat ()
Packit 7cfc04
function operates in exactly the same way as
Packit 7cfc04
.BR mkfifo (),
Packit 7cfc04
except for the differences described here.
Packit 7cfc04
.PP
Packit 7cfc04
If the pathname given in
Packit 7cfc04
.I pathname
Packit 7cfc04
is relative, then it is interpreted relative to the directory
Packit 7cfc04
referred to by the file descriptor
Packit 7cfc04
.I dirfd
Packit 7cfc04
(rather than relative to the current working directory of
Packit 7cfc04
the calling process, as is done by
Packit 7cfc04
.BR mkfifo ()
Packit 7cfc04
for a relative pathname).
Packit 7cfc04
.PP
Packit 7cfc04
If
Packit 7cfc04
.I pathname
Packit 7cfc04
is relative and
Packit 7cfc04
.I dirfd
Packit 7cfc04
is the special value
Packit 7cfc04
.BR AT_FDCWD ,
Packit 7cfc04
then
Packit 7cfc04
.I pathname
Packit 7cfc04
is interpreted relative to the current working
Packit 7cfc04
directory of the calling process (like
Packit 7cfc04
.BR mkfifo ()).
Packit 7cfc04
.PP
Packit 7cfc04
If
Packit 7cfc04
.I pathname
Packit 7cfc04
is absolute, then
Packit 7cfc04
.I dirfd
Packit 7cfc04
is ignored.
Packit 7cfc04
.SH RETURN VALUE
Packit 7cfc04
On success
Packit 7cfc04
.BR mkfifo ()
Packit 7cfc04
and
Packit 7cfc04
.BR mkfifoat ()
Packit 7cfc04
return 0.
Packit 7cfc04
In the case of an error, \-1 is returned (in which case, \fIerrno\fP
Packit 7cfc04
is set appropriately).
Packit 7cfc04
.SH ERRORS
Packit 7cfc04
.TP
Packit 7cfc04
.B EACCES
Packit 7cfc04
One of the directories in \fIpathname\fP did not allow search
Packit 7cfc04
(execute) permission.
Packit 7cfc04
.TP
Packit 7cfc04
.B EDQUOT
Packit 7cfc04
The user's quota of disk blocks or inodes on the filesystem has been
Packit 7cfc04
exhausted.
Packit 7cfc04
.TP
Packit 7cfc04
.B EEXIST
Packit 7cfc04
\fIpathname\fP already exists.
Packit 7cfc04
This includes the case where
Packit 7cfc04
.I pathname
Packit 7cfc04
is a symbolic link, dangling or not.
Packit 7cfc04
.TP
Packit 7cfc04
.B ENAMETOOLONG
Packit 7cfc04
Either the total length of \fIpathname\fP is greater than
Packit 7cfc04
\fBPATH_MAX\fP, or an individual filename component has a length
Packit 7cfc04
greater than \fBNAME_MAX\fP.
Packit 7cfc04
In the GNU system, there is no imposed
Packit 7cfc04
limit on overall filename length, but some filesystems may place
Packit 7cfc04
limits on the length of a component.
Packit 7cfc04
.TP
Packit 7cfc04
.B ENOENT
Packit 7cfc04
A directory component in \fIpathname\fP does not exist or is a
Packit 7cfc04
dangling symbolic link.
Packit 7cfc04
.TP
Packit 7cfc04
.B ENOSPC
Packit 7cfc04
The directory or filesystem has no room for the new file.
Packit 7cfc04
.TP
Packit 7cfc04
.B ENOTDIR
Packit 7cfc04
A component used as a directory in \fIpathname\fP is not, in fact, a
Packit 7cfc04
directory.
Packit 7cfc04
.TP
Packit 7cfc04
.B EROFS
Packit 7cfc04
\fIpathname\fP refers to a read-only filesystem.
Packit 7cfc04
.PP
Packit 7cfc04
The following additional errors can occur for
Packit 7cfc04
.BR mkfifoat ():
Packit 7cfc04
.TP
Packit 7cfc04
.B EBADF
Packit 7cfc04
.I dirfd
Packit 7cfc04
is not a valid file descriptor.
Packit 7cfc04
.TP
Packit 7cfc04
.B ENOTDIR
Packit 7cfc04
.I pathname
Packit 7cfc04
is a relative path and
Packit 7cfc04
.I dirfd
Packit 7cfc04
is a file descriptor referring to a file other than a directory.
Packit 7cfc04
.SH VERSIONS
Packit 7cfc04
.BR mkfifoat ()
Packit 7cfc04
was added to glibc in version 2.4.
Packit 7cfc04
It is implemented using
Packit 7cfc04
.BR mknodat (2),
Packit 7cfc04
available on Linux since kernel 2.6.16.
Packit 7cfc04
.SH ATTRIBUTES
Packit 7cfc04
For an explanation of the terms used in this section, see
Packit 7cfc04
.BR attributes (7).
Packit 7cfc04
.TS
Packit 7cfc04
allbox;
Packit 7cfc04
lbw20 lb lb
Packit 7cfc04
l l l.
Packit 7cfc04
Interface	Attribute	Value
Packit 7cfc04
T{
Packit 7cfc04
.BR mkfifo (),
Packit 7cfc04
.BR mkfifoat ()
Packit 7cfc04
T}	Thread safety	MT-Safe
Packit 7cfc04
.TE
Packit 7cfc04
.SH CONFORMING TO
Packit 7cfc04
.BR mkfifo ():
Packit 7cfc04
POSIX.1-2001, POSIX.1-2008.
Packit 7cfc04
.PP
Packit 7cfc04
.BR mkfifoat ():
Packit 7cfc04
POSIX.1-2008.
Packit 7cfc04
.SH SEE ALSO
Packit 7cfc04
.BR mkfifo (1),
Packit 7cfc04
.BR close (2),
Packit 7cfc04
.BR open (2),
Packit 7cfc04
.BR read (2),
Packit 7cfc04
.BR stat (2),
Packit 7cfc04
.BR umask (2),
Packit 7cfc04
.BR write (2),
Packit 7cfc04
.BR fifo (7)
Packit 7cfc04
.SH COLOPHON
Packit 7cfc04
This page is part of release 4.15 of the Linux
Packit 7cfc04
.I man-pages
Packit 7cfc04
project.
Packit 7cfc04
A description of the project,
Packit 7cfc04
information about reporting bugs,
Packit 7cfc04
and the latest version of this page,
Packit 7cfc04
can be found at
Packit 7cfc04
\%https://www.kernel.org/doc/man\-pages/.