Guardian Native C Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)
ftok(3) Guardian Native C Library Calls Reference Manual
NAME
ftok - Generates an OSS interprocess communication (IPC) key
LIBRARY
G-series native Guardian processes: system library
G-series native OSS processes: system library
H-series and J-series native Guardian processes: implicit libraries
H-series and J-series OSS processes: implicit libraries
SYNOPSIS
#include <sys/ipc.h>
key_t ftok(
const char *path_name,
int id);
PARAMETERS
path_name Specifies the pathname of an existing file. The same file must be used by the
process with which interprocess communication is required. The calling process
must have execute (search) permission on all filename components in the
specified pathname except for the last. The named file must be accessible (a call
to the stat() function must succeed).
id Specifies a character, such as a project ID, with a value in the range 1 through
255 that uniquely identifies an interprocess communication effort among all
those using the same specified file.
Bits <0:23> are ignored. If the entire id parameter is zero--that is, if the charac-
ter is a null (\0)--the value of the st_ino field for the named file is returned.
DESCRIPTION
The ftok( ) function returns a key that is composed from the path_name parameter and the id
parameter. This key is then used to obtain interprocess communication identifiers.
The ftok( ) function 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. For example, an
application with multiple parts can use the ftok( ) function to specify unique keys for the same
path_name.
If the path_name parameter specifies a file that has been removed while keys still refer to it, then
the ftok( ) function returns an error. If that file is then recreated, the ftok( ) function might return
a different key than the original one.
Interprocess communication facilities require you to supply a key to the msgget(), semget(),or
shmget() function in order to obtain interprocess communication identifiers. The ftok( ) function
provides one method of creating keys, but many others are possible.
Use From the Guardian Environment
The ftok( ) function can be used by a Guardian process when the process has been compiled
using the #define _XOPEN_SOURCE_EXTENDED 1 feature-test macro or an equivalent com-
piler command option.
The ftok( ) function is one of a set of functions that have the following effects when the first of
them is called from the Guardian environment:
• Two Guardian file system file numbers (not necessarily the next two available) are allo-
cated for the root directory and the current working directory. These file numbers cannot
be closed by calling the Guardian FILE_CLOSE_ procedure.
2−154 Hewlett-Packard Company 527192-018