ftok(S)
ftok --
standard interprocess communication package
Syntax
cc . . . -lc
#include <sys/types.h>
#include <sys/ipc.h>
key_t ftok(path, id)
char *path;
char id;
Description
All interprocess communication facilities
require you to supply a key that the
msgget(S),
semget(S),
and
shmget(S)
system calls use to obtain interprocess communication identifiers.
One suggested method for forming a key
is to use the ftok subroutine.
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 many other ways to form keys,
but it is necessary for each system
to define standards for forming them.
If a standard is not adhered to,
unrelated processes may conflict.
Therefore,
the most significant byte of a key should
refer to a project.
ftok returns a key based on
path and id
that is usable 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.
ftok returns the same key
for linked files when called with the same
id and returns different keys when
called with the same file name but different ids.
Diagnostics
ftok returns (key_t) -1
if path does not exist or is not accessible
to the process.
Warning
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
return an error.
If the same file is recreated, then ftok
is likely to return a different key
than it did the first time it was called.
See also
Intro(S),
msgget(S),
semget(S),
shmget(S)
Standards conformance
ftok is not part of any currently supported standard;
it is an extension of AT&T System V provided by the Santa Cruz Operation.
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003