Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ftok(3) — OSF/1 1.0 (TIN) MIPS

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

msgget(2)

semget(2)

shmget(2)

ftok(3)  —  Subroutines

OSF

NAME

ftok − Generates a standard interprocess communication key

LIBRARY

Standard C Library (libc.a)

SYNOPSIS

#include <sys/types.h>
#include <sys/ipc.h>

key_t ftok (
char ∗path_name,
char project_id );

PARAMETERS

path_nameSpecifies the pathname of an existing file that is accessible to the process. 

project_idSpecifies a character that uniquely identifies a project. 

DESCRIPTION

The ftok() function returns a key, based on the path_name and project_id parameters, to be used to obtain interprocess communication identifiers.  The ftok() function returns the same key for linked files if called with the same project_id parameter.  Different keys are returned for the same file if different project_id parameters are used. 

Interprocess communication facilities require you to supply a key to the msgget(), semget(), and shmget() functions in order to obtain interprocess communication identifiers. The ftok() function provides one method of creating keys, but many others are possible.  For example, you can use the project ID as the most significant byte of the key, and use the remaining portion as a sequence number. 

CAUTION

It is important for each installation to define standards for forming keys. If some standard is not adhered to, it is possible for unrelated processes to interfere with each other’s operation. 

RETURN VALUES

Upon successful completion, the ftok() function returns a key that can be passed to the msgget(), semget(), or shmget() function. The ftok() function returns the value (key_t)-1 if any of the following are true:

       •The file named by the path_name parameter does not exist. 

       •The file named by the path_name parameter is not accessible to the process. 

       •The project_id parameter is 0 (zero) or the null string (”). 

If the path_name parameter of the ftok() function names 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 may return a different key than the original one. 

RELATED INFORMATION

Functions: msgget(2), semget(2), shmget(2)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026