'\"macro stdmacro
.if n .pH g3c.stdipc @(#)stdipc	40.7 of 10/10/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} stdipc 3C "C Programming Language Utilities" "\&"
.if \nX=1 .ds x} stdipc 3C "C Programming Language Utilities"
.if \nX=2 .ds x} stdipc 3C "" "\&"
.if \nX=3 .ds x} stdipc "" "" "\&"
.TH \*(x}
.SH NAME
\f4stdipc\f2: \f4ftok\f1 \- standard interprocess communication package
.SH SYNOPSIS
.nf
\f4#include <sys/types.h>\f1
\f4#include <sys/ipc.h>\f1
.PP
\f4key_t ftok(const char \(**path, int id);\f1
.fi
.SH DESCRIPTION
All interprocess communication facilities
require the user to supply a key
to be used by the
\f4msgget\fP(2),
\f4semget\fP(2),
and
\f4shmget\fP(2)
system calls to obtain interprocess communication identifiers.
One suggested method for forming a key
is to use the
\f4ftok\fP
subroutine described below.
Another way to compose keys
is to include the project \s-1ID\s+1 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 some standard is not adhered to,
it will be possible for unrelated processes
to unintentionally interfere with
each other's operation.
It is still possible to interface intentionally.
Therefore,
it is strongly suggested that
the most significant byte of a key
in some sense
refer to a project
so that keys do not conflict
across a given system.
.PP
\f4ftok\fP
returns a key
based on
.I path
and \f2id\fP
that is usable in subsequent
\f4msgget\fP,
\f4semget\fP,
and
\f4shmget\fP
system calls.
.I path
must be the path name
of an existing file
that is accessible
to the process.
\f2id\fP
is a character
that uniquely identifies
a project.
Note that
\f4ftok\fP
will return the same key
for linked files
when called with the same
\f2id\fP
and that it will return
different keys when
called with the same file name
but different
.IR ids .
.SH "SEE ALSO"
\f4intro\fP(2),
\f4msgget\fP(2),
\f4semget\fP(2),
\f4shmget\fP(2).
.SH DIAGNOSTICS
\f4ftok\f1
returns
\f4(key_t) \-1\f1
if \f2path\fP
does not exist
or if it is not accessible
to the process.
.SH NOTES
If the file whose \f2path\fP is passed
to
\f4ftok\f1
is removed when keys still refer to the file,
future calls to
\f4ftok\f1
with the same \f2path\fP and \f2id\fP
will return an error.
If the same file is recreated,
then
\f4ftok\f1
is likely to return a different key
than it did the original time it was called.
.\"	@(#)stdipc.3c	6.2 of 10/20/83
.Ee
