STDIPC(3C) DOMAIN/IX SYS5 STDIPC(3C)
NAME
ftok - interprocess communication package
USAGE
#include <sys/types.h>
#include <sys/ipc.h>
key_t ftok(path, id)
char *path;
char id;
DESCRIPTION
All of the System V interprocess communication facilities
require the user to supply a key for the msgget(2),
semget(2), and shmget(2) system calls to use when obtaining
interprocess communication identifiers. One method for
forming a key is to use the ftok subroutine.
Ftok returns a key based on path and id that is useable in
subsequent msgget, semget, and shmget system calls. Path
must be the pathname of an existing file that is accessible
to the process. Id is a character which uniquely identifies
a project. Note that ftok will return the same key for
linked files when called with the same id and that it will
return different keys if you call it with the same filename
but different ids.
NOTES
Another way to compose keys is to include the project ID in
the most significant byte and to use the remaining portion
as a sequence number. There are other ways to form keys,
but unless a standard for forming them is established, it
will be possible for unrelated processes to interfere, unin-
tentionally, with each other's operation. Therefore, making
the most significant byte of a key refer, in some way, to a
project will ensure that keys do not conflict across a given
system.
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, then ftok is likely to return a different key
than it did the original time it was called.
DIAGNOSTICS
Ftok returns (key_t) -1 if path does not exist or is not
accessible to the process.
Printed 12/4/86 STDIPC-1
STDIPC(3C) DOMAIN/IX SYS5 STDIPC(3C)
RELATED INFORMATION
msgget(2), semget(2), shmget(2)
STDIPC-2 Printed 12/4/86