English pages are provided only to compare translations to original pages,
better looking pages can be browsed
at the Linux man-pages official site.
Linux Programmer's Manual (3)
ftok - convert a pathname and a project identifier to a System V IPC key
key_t ftok(const char *pathname, int proj_id);
function uses the identity of the file named by the given
(which must refer to an existing, accessible file)
and the least significant 8 bits of
(which must be nonzero) to generate a
type System V IPC key, suitable for use with
The resulting value is the same for all pathnames that
name the same file, when the same value of
The value returned should be different when the
(simultaneously existing) files or the project IDs differ.
On success, the generated
value is returned.
On failure -1 is returned, with
indicating the error as for the
Multithreading (see pthreads(7))
function is thread-safe.
Under libc4 and libc5 (and under SunOS 4.x) the prototype was:
key_t ftok(char *pathname, char proj_id);
but still only 8 bits are used.
Typical usage has an ASCII character
that is why the behavior is said to be undefined when
Of course no guarantee can be given that the resulting
Typically, a best effort attempt combines the given
byte, the lower 16 bits of the inode number, and the
lower 8 bits of the device number into a 32-bit result.
Collisions may easily happen, for example between files on
and files on
This page is part of release 3.66 of the Linux
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
- RETURN VALUE
- Multithreading (see pthreads(7))
- CONFORMING TO
- SEE ALSO
This document was created by
using the manual pages.
Time: 21:43:00 GMT, July 12, 2014