📄 ftok.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>ftok</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_000_005_356"> </a>NAME</h4><blockquote>ftok - generate an IPC key</blockquote><h4><a name = "tag_000_005_357"> </a>SYNOPSIS</h4><blockquote><pre><code>#include <<a href="sysipc.h.html">sys/ipc.h</a>>key_t ftok(const char *<i>path</i>, int <i>id</i>);</code></pre></blockquote><h4><a name = "tag_000_005_358"> </a>DESCRIPTION</h4><blockquote>The<i>ftok()</i>function returns a key based on<i>path</i>and <i>id</i> that is usable in subsequent calls to<i><a href="msgget.html">msgget()</a></i>,<i><a href="semget.html">semget()</a></i>and<i><a href="shmget.html">shmget()</a></i>.The<i>path</i>argument must be the pathname of an existing file that the process is able to<i><a href="stat.html">stat()</a></i>.<p>The<i>ftok()</i>function will return the same key value for all paths that name the same file,when called with the same <i>id</i> value, and will return different key valueswhen called with different <i>id</i> values or with paths that name differentfiles existing on the same file system at the same time.It is unspecified whether<i>ftok()</i>returns the same key value when called again after the file named by<i>path</i>is removed and recreated with the same name.<p>Only the low order 8-bits of <i>id</i> are significant. The behaviour of<i>ftok()</i>is unspecified if these bits are 0.</blockquote><h4><a name = "tag_000_005_359"> </a>RETURN VALUE</h4><blockquote>Upon successful completion,<i>ftok()</i>returns a key. Otherwise,<i>ftok()</i>returns (<b>key_t</b>)-1 and sets <i>errno</i> to indicate the error.</blockquote><h4><a name = "tag_000_005_360"> </a>ERRORS</h4><blockquote>The<i>ftok()</i>function will fail if:<dl compact><dt>[EACCES]<dd>Search permission is denied for a component of the path prefix.<dt>[ELOOP]<dd>Too many symbolic links were encountered in resolving <i>path</i>.<dt>[ENAMETOOLONG]<dd>The length of the <i>path</i> argument exceeds {PATH_MAX} or apathname component is longer than {NAME_MAX}.<dt>[ENOENT]<dd>A component of <i>path</i> does not name an existing fileor <i>path</i> is an empty string.<dt>[ENOTDIR]<dd>A component of the path prefix is not a directory.</dl><p>The<i>ftok()</i>function may fail if:<dl compact><dt>[ENAMETOOLONG]<dd>Pathname resolution of a symbolic link produced an intermediate result whoselength exceeds {PATH_MAX}.</dl></blockquote><h4><a name = "tag_000_005_361"> </a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_000_005_362"> </a>APPLICATION USAGE</h4><blockquote>For maximum portability,<i>id</i>should be a single-byte character.</blockquote><h4><a name = "tag_000_005_363"> </a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_000_005_364"> </a>SEE ALSO</h4><blockquote><i><a href="msgget.html">msgget()</a></i>,<i><a href="semget.html">semget()</a></i>,<i><a href="shmget.html">shmget()</a></i>,<i><a href="sysipc.h.html"><sys/ipc.h></a></i>.</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -