Generates a standard interprocess communication key.
Standard C Library (libc.a)
The ftok subroutine returns a key, based on the Path and ID parameters, to be used to obtain interprocess communication identifiers. The ftok subroutine 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.
All interprocess communication facilities require you to supply a key to the msgget, semget, and shmget subroutines in order to obtain interprocess communication identifiers. The ftok subroutine provides one method for creating keys, but other methods 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.
Item | Description |
---|---|
Path | Specifies the path name of an existing file that is accessible to the process. |
ID | Specifies a character that uniquely identifies a project. |
When successful, the ftok subroutine returns a key that can be passed to the msgget, semget, or shmget subroutine.
The ftok subroutine returns the value (key_t)-1 if one or more of the following are true: