STDIPC(3,L) AIX Technical Reference STDIPC(3,L)
-------------------------------------------------------------------------------
stdipc: ftok
PURPOSE
Generates a standard interprocess communication key.
LIBRARY
Standard C Library (libc.a)
SYNTAX
#include <sys/types.h>
#include <sys/ipc.h>
key_t ftok (path, id)
char *path;
char id;
DESCRIPTION
The ftok subroutine returns a key, based on the path and id parameters, to be
used to obtain interprocess communication identifiers. The path parameter must
be the path name of an existing file that is accessible to the process. The id
parameter must be a character that uniquely identifies a project. ftok returns
the same key for linked files if called with the same id parameter. Different
keys are returned for the same file if different id parameters are used.
All interprocess communication facilities require you to supply a key to the
msgget, semget, and shmget system calls in order to obtain interprocess
communication identifiers. The ftok subroutine provides one method of creating
keys, but many others are possible. Another way to do this, for example, is to
use the project ID as the most significant byte of the key, and to use the
remaining portion as a sequence number.
Warning: It is important for each installation to define standards for forming
keys. If some standard is not adhered to, unrelated processes can interfere
with each other's operation.
If the path parameter of the ftok subroutine names a file that has been removed
while keys still refer it, then the ftok subroutine returns an error. If that
file is then recreated, the ftok subroutine will probably return a different
key than the original one.
RETURN VALUE
Upon successful completion, the ftok subroutine returns a key that can be
passed to the msgget, semget, or shmget system call. The ftok subroutine
returns (key_t) -1 if one or more of the following are true:
Processed November 7, 1990 STDIPC(3,L) 1
STDIPC(3,L) AIX Technical Reference STDIPC(3,L)
o The file named by the path parameter does not exist.
o The file named by the path parameter is not accessible to the process.
o The id parameter is 0 ("'\0'").
RELATED INFORMATION
In this book: "msgget," "semget," and "shmget."
Processed November 7, 1990 STDIPC(3,L) 2