ftok.3c (2010 09)

f
ftok(3C) ftok(3C)
NAME
ftok( ) - create interprocess communication identifier
SYNOPSIS
#include <sys/ipc.h>
key_t ftok(const char *path, int id);
DESCRIPTION
All interprocess communication facilities require the user to supply a key to be used by the
msgget(),
semget(), and shmget() system calls to obtain interprocess communication identifiers (see msgget(2),
semget(2), and shmget(2)).
ftok() returns a key based on path and id that is usable in subsequent
msgget(), semget(), and
shmget() system calls.
The parameters for the
ftok() function are as follows:
path must be the path name of an existing file that is accessible to the process.
id is a character that uniquely identifies a project. This means that only the low
order 8-bits of id are significant. Note that
ftok() returns the same key for
linked files when called with the same id and that it returns different keys
when called with the same file name but different id s.
RETURN VALUE
ftok() returns (key_t)-1 if path does not exist or if it is not accessible to the process.
EXAMPLES
The following call to
ftok() returns a key associated with the file myfile and id
A:
key_t mykey;
mykey = ftok ("myfile", ’A’);
WARNINGS
If the file whose path is passed to ftok() is removed when keys still refer to the file, future calls to
ftok() with the same path and id will return an error. If the same file is recreated,
ftok() is likely
to return a different key than it did the original time it was called.
SEE ALSO
intro(2), msgget(2), semget(2), shmget(2), thread_safety(5).
HP-UX 11i Version 3: September 2010 1 Hewlett-Packard Company 1

Summary of content (2 pages)