Name

ftok - converts a pathname and a project identifier to a System V IPC key

Library

libc.lib

Synopsis

  #include <sys/types.h>
  #include <sys/ipc.h>
  key_t ftok (const char *path, int id);

Return values

The ftok function will return -1 if path does not exist or if it cannot be accessed by the calling process. On success the generated key_t value is returned.

Detailed description

The ftok function attempts to create a unique key suitable for use with the msgget, semget and shmget functions given the path of an existing file and a user-selectable id.

The specified path must specify an existing file that is accessible to the calling process or the call will fail. Also, note that links to files will return the same key, given the same id.


Examples

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

         
int main(void)
{
    char *pathame = "C:\\XXX";
    int proj_id = 100;
    key_t fkey;
    if ((fkey = ftok(pathame, proj_id)) == -1) {
        printf("ftok() failed\n");
    }
    return 0;
}

         


See also

semget, shmget, msgget


Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top