Guardian Native C Library Calls Reference Manual (G06.28+, H06.04+)

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 native Guardian processes: implicit libraries
H-series OSS processes: implicit libraries
SYNOPSIS
#include <sys/ipc.h>
key_t ftok(
const char *path_name,
int id);
PARAMETERS
path_name Species the pathname of an existing le. The same le must be used by the
process with which interprocess communication is required. The calling process
must have execute (search) permission on all lename components in the
specied pathname except for the last. The named le must be accessible (a call
to the stat() function must succeed).
id Species a character, such as a project ID, with a value in the range 1 through
255 that uniquely identies an interprocess communication effort among all
those using the same specied le.
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 eld for the named le 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 identiers.
The ftok( ) function returns the same key for linked les if called with the same id parameter.
Different keys are returned for the same le 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 species a le that has been removed while keys still refer to it, then
the ftok( ) function returns an error. If that le 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 identiers. 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 #dene _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 rst of
them is called from the Guardian environment:
Two Guardian le system le numbers (not necessarily the next two available) are allo-
cated for the root directory and the current working directory. These le numbers cannot
be closed by calling the Guardian FILE_CLOSE_ procedure.
280 Hewlett-Packard Company 527192-005