Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > F

ftok(3C)

HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

ftok() — create interprocess communication identifier

SYNOPSIS

#include <sys/ipc.h>

key_t ftok(const char *path, int id);

DESCRIPTION

All interprocess communication facilities require the user to supply a key to be used by the msgget(), semget(), and shmget() system calls to obtain interprocess communication identifiers (see msgget(2), semget(2), and shmget(2)).

ftok() returns a key based on path and id that is usable in subsequent msgget(), semget(), and shmget() system calls.

The parameters for the ftok() function are as follows:

path

must be the path name of an existing file that is accessible to the process.

id

is a character that uniquely identifies a project. This means that only the low order 8-bits of id are significant. Note that ftok() returns the same key for linked files when called with the same id and that it returns different keys when called with the same file name but different ids.

RETURN VALUE

ftok() returns (key_t)-1 if path does not exist or if it is not accessible to the process.

EXAMPLES

The following call to ftok() returns a key associated with the file myfile and id A:

key_t mykey; mykey = ftok ("myfile", 'A');

WARNINGS

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 will return an error. If the same file is recreated, ftok() is likely to return a different key than it did the original time it was called.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.