Files
oldlinux-files/Ref-docs/POSIX/susv3/functions/mkfifo.html
2024-02-19 00:21:47 -05:00

234 lines
8.3 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
<title>mkfifo</title>
</head>
<body bgcolor="white">
<basefont size="3"> <a name="mkfifo"></a> <a name="tag_03_372"></a><!-- mkfifo -->
<!--header start-->
<center><font size="2">The Open Group Base Specifications Issue 6<br>
IEEE Std 1003.1-2001<br>
Copyright &copy; 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
<!--header end-->
<hr size="2" noshade>
<h4><a name="tag_03_372_01"></a>NAME</h4>
<blockquote>mkfifo - make a FIFO special file</blockquote>
<h4><a name="tag_03_372_02"></a>SYNOPSIS</h4>
<blockquote class="synopsis">
<p><code><tt>#include &lt;<a href="../basedefs/sys/stat.h.html">sys/stat.h</a>&gt;<br>
<br>
int mkfifo(const char *</tt><i>path</i><tt>, mode_t</tt> <i>mode</i><tt>);<br>
</tt></code></p>
</blockquote>
<h4><a name="tag_03_372_03"></a>DESCRIPTION</h4>
<blockquote>
<p>The <i>mkfifo</i>() function shall create a new FIFO special file named by the pathname pointed to by <i>path</i>. The file
permission bits of the new FIFO shall be initialized from <i>mode</i>. The file permission bits of the <i>mode</i> argument shall
be modified by the process' file creation mask.</p>
<p>When bits in <i>mode</i> other than the file permission bits are set, the effect is implementation-defined.</p>
<p>If <i>path</i> names a symbolic link, <i>mkfifo</i>() shall fail and set <i>errno</i> to [EEXIST].</p>
<p>The FIFO's user ID shall be set to the process' effective user ID. The FIFO's group ID shall be set to the group ID of the
parent directory or to the effective group ID of the process. Implementations shall provide a way to initialize the FIFO's group ID
to the group ID of the parent directory. Implementations may, but need not, provide an implementation-defined way to initialize the
FIFO's group ID to the effective group ID of the calling process.</p>
<p>Upon successful completion, <i>mkfifo</i>() shall mark for update the <i>st_atime</i>, <i>st_ctime</i>, and <i>st_mtime</i>
fields of the file. Also, the <i>st_ctime</i> and <i>st_mtime</i> fields of the directory that contains the new entry shall be
marked for update.</p>
</blockquote>
<h4><a name="tag_03_372_04"></a>RETURN VALUE</h4>
<blockquote>
<p>Upon successful completion, 0 shall be returned. Otherwise, -1 shall be returned, no FIFO shall be created, and <i>errno</i>
shall be set to indicate the error.</p>
</blockquote>
<h4><a name="tag_03_372_05"></a>ERRORS</h4>
<blockquote>
<p>The <i>mkfifo</i>() function shall fail if:</p>
<dl compact>
<dt>[EACCES]</dt>
<dd>A component of the path prefix denies search permission, or write permission is denied on the parent directory of the FIFO to
be created.</dd>
<dt>[EEXIST]</dt>
<dd>The named file already exists.</dd>
<dt>[ELOOP]</dt>
<dd>A loop exists in symbolic links encountered during resolution of the <i>path</i> argument.</dd>
<dt>[ENAMETOOLONG]</dt>
<dd>
The length of the <i>path</i> argument exceeds {PATH_MAX} or a pathname component is longer than {NAME_MAX}.</dd>
<dt>[ENOENT]</dt>
<dd>A component of the path prefix specified by <i>path</i> does not name an existing directory or <i>path</i> is an empty
string.</dd>
<dt>[ENOSPC]</dt>
<dd>The directory that would contain the new file cannot be extended or the file system is out of file-allocation resources.</dd>
<dt>[ENOTDIR]</dt>
<dd>A component of the path prefix is not a directory.</dd>
<dt>[EROFS]</dt>
<dd>The named file resides on a read-only file system.</dd>
</dl>
<p>The <i>mkfifo</i>() function may fail if:</p>
<dl compact>
<dt>[ELOOP]</dt>
<dd>More than {SYMLOOP_MAX} symbolic links were encountered during resolution of the <i>path</i> argument.</dd>
<dt>[ENAMETOOLONG]</dt>
<dd>
As a result of encountering a symbolic link in resolution of the <i>path</i> argument, the length of the substituted pathname
string exceeded {PATH_MAX}.</dd>
</dl>
</blockquote>
<hr>
<div class="box"><em>The following sections are informative.</em></div>
<h4><a name="tag_03_372_06"></a>EXAMPLES</h4>
<blockquote>
<h5><a name="tag_03_372_06_01"></a>Creating a FIFO File</h5>
<p>The following example shows how to create a FIFO file named <b>/home/cnd/mod_done</b>, with read/write permissions for owner,
and with read permissions for group and others.</p>
<pre>
<tt>#include &lt;sys/types.h&gt;
#include &lt;sys/stat.h&gt;
<br>
int status;
...
status = mkfifo("/home/cnd/mod_done", S_IWUSR | S_IRUSR |
S_IRGRP | S_IROTH);
</tt>
</pre>
</blockquote>
<h4><a name="tag_03_372_07"></a>APPLICATION USAGE</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_372_08"></a>RATIONALE</h4>
<blockquote>
<p>The syntax of this function is intended to maintain compatibility with historical implementations of <a href=
"../functions/mknod.html"><i>mknod</i>()</a>. The latter function was included in the 1984 /usr/group standard but only for use in
creating FIFO special files. The <a href="../functions/mknod.html"><i>mknod</i>()</a> function was originally excluded from the
POSIX.1-1988 standard as implementation-defined and replaced by <a href="../functions/mkdir.html"><i>mkdir</i>()</a> and
<i>mkfifo</i>(). The <a href="../functions/mknod.html"><i>mknod</i>()</a> function is now included for alignment with the Single
UNIX Specification.</p>
<p>The POSIX.1-1990 standard required that the group ID of a newly created FIFO be set to the group ID of its parent directory or
to the effective group ID of the creating process. FIPS 151-2 required that implementations provide a way to have the group ID be
set to the group ID of the containing directory, but did not prohibit implementations also supporting a way to set the group ID to
the effective group ID of the creating process. Conforming applications should not assume which group ID will be used. If it
matters, an application can use <a href="../functions/chown.html"><i>chown</i>()</a> to set the group ID after the FIFO is created,
or determine under what conditions the implementation will set the desired group ID.</p>
</blockquote>
<h4><a name="tag_03_372_09"></a>FUTURE DIRECTIONS</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_372_10"></a>SEE ALSO</h4>
<blockquote>
<p><a href="umask.html"><i>umask</i>()</a> , the Base Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href=
"../basedefs/sys/stat.h.html"><i>&lt;sys/stat.h&gt;</i></a>, <a href=
"../basedefs/sys/types.h.html"><i>&lt;sys/types.h&gt;</i></a></p>
</blockquote>
<h4><a name="tag_03_372_11"></a>CHANGE HISTORY</h4>
<blockquote>
<p>First released in Issue 3. Included for alignment with the POSIX.1-1988 standard.</p>
</blockquote>
<h4><a name="tag_03_372_12"></a>Issue 6</h4>
<blockquote>
<p>In the SYNOPSIS, the optional include of the <a href="../basedefs/sys/types.h.html"><i>&lt;sys/types.h&gt;</i></a> header is
removed.</p>
<p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p>
<ul>
<li>
<p>The requirement to include <a href="../basedefs/sys/types.h.html"><i>&lt;sys/types.h&gt;</i></a> has been removed. Although <a
href="../basedefs/sys/types.h.html"><i>&lt;sys/types.h&gt;</i></a> was required for conforming implementations of previous POSIX
specifications, it was not required for UNIX applications.</p>
</li>
<li>
<p>The [ELOOP] mandatory error condition is added.</p>
</li>
<li>
<p>A second [ENAMETOOLONG] is added as an optional error condition.</p>
</li>
</ul>
<p>The following changes were made to align with the IEEE&nbsp;P1003.1a draft standard:</p>
<ul>
<li>
<p>The [ELOOP] optional error condition is added.</p>
</li>
</ul>
</blockquote>
<div class="box"><em>End of informative text.</em></div>
<hr>
<hr size="2" noshade>
<center><font size="2"><!--footer start-->
UNIX &reg; is a registered Trademark of The Open Group.<br>
POSIX &reg; is a registered Trademark of The IEEE.<br>
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
]</font></center>
<!--footer end-->
<hr size="2" noshade>
</body>
</html>