Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

ftok(3) [ultrix man page]

ftok(3) 						     Library Functions Manual							   ftok(3)

Name
       ftok - standard interprocess communication package

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

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

Description
       All interprocess communication facilities require the user to supply a key to be used by the and system calls to obtain interprocess commu-
       nication identifiers.  One suggested method for forming a key is to use the file to key, subroutine described below.  Another way  to  com-
       pose  keys is to include the project ID 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.  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.

       The subroutine returns a key based on path and id that is usable in subsequent and system calls.  The path must be  the	path  name  of	an
       existing  file  that  is  accessible to the process.  The id is a character which uniquely identifies a project.  Note that will return the
       same key for linked files when called with the same id and that it will return different keys when called with the same file name but  dif-
       ferent ids.

Return Values
       The subroutine returns (key_t) -1 if path does not exist or if it is not accessible to the process.

Warning
       If  the file whose path is passed to is removed when keys still refer to the file, future calls to with the same path and id will return an
       error.  If the same file is recreated, then is likely to return a different key than it did the original time it was called.

See Also
       intro(2), msgget(2), semget(2), shmget(2)

																	   ftok(3)

Check Out this Related Man Page

ftok(3) 						     Library Functions Manual							   ftok(3)

NAME
ftok - Generates a standard interprocess communication key LIBRARY
Standard C Library (libc.so, libc.a) SYNOPSIS
#include <sys/ipc.h> key_t ftok( const char *path_name, int project_id ); The following definition of the ftok() function does not conform to current standards and is supported only for backward compatibility: #include <sys/types.h> #include <sys/ipc.h> key_t ftok( char *path_name, char project_id ); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: ftok(): XPG4-UNIX Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Specifies the pathname of an existing file that is accessible to the process. Specifies a value that uniquely identifies a project. DESCRIPTION
The ftok() function returns a key, based on the path_name and project_id parameters, that is usable in subsequent calls to the msgget(), semget(), and shmget() functions. The ftok() function returns the same key for all paths that name the same file, when called with the same project_id parameter. Different keys are returned for the same file if different project_id parameters are used, or if paths are used that name different files existing on the same file system at the same time. If a file named by path_name is removed and recreated with the same name, the ftok() function may return a different key than the original one. Only the low order 8-bits of project_id are significant. The behavior of ftok() is unspecified if these bits are 0. For maximum portability, project_id should be a single-byte character. RETURN VALUES
Upon successful completion, the ftok() function returns a key. Otherwise, ftok() returns the value (key_t)-1 and sets errno to indicate the error. ERRORS
The ftok() function sets errno to the specified values for the following conditions: Search permission is denied for a component of the path_name parameter. Too many symbolic links were encountered in resolving path_name. The length of the path_name parameter exceeds PATH_MAX, or a pathname component is longer than NAME_MAX. Or, pathname resolution of a symbolic link produced an intermediate result whose length exceeds PATH_MAX. The path_name parameter points to the name of a file that does not exist or points to an empty string. A component of the path_name parameter is not a directory. RELATED INFORMATION
Functions: msgget(2), semget(2), shmget(2) Standards: standards(5) delim off ftok(3)
Man Page