ftok

Creates a key to use with the semget function.

Library:LibC
Classification:System-V
Service:Synchronization

Syntax

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

Parameters

path

(IN) Points to the path of an accessible file. You can set the value to ".", a directory entry which is always present.

id

(IN) Specifies an integer value.

Return Values

If successful, returns a key value. Otherwise, returns -1 and sets errno.

Decimal

Constant

Description

1

ENOENT

A component of path does not name an existing file, or the path parameter is an empty string.

6

EACCES

The caller does not have search permission for a component of the path.

65

ENAMETOOLONG

The path parameter or a pathname component is longer than the maximum allowed length.

67

ENOTDIR

A component of the path argument is not a directory.

Remarks

If two processes specify the same path and id, the NetWare® operating system creates a system wide key that multiple applications can share. If two or more applications use the same path and id, NetWare returns the same key value, which allows them to share the global semaphore. The following console command displays all global semaphores:

     IPCS
  

The IPCRM console command can be used to delete a global semaphore. Usually, an application using global semaphores cleans them up before exiting, but if application ends abnormally and fails to clean them up, you can use this command to remove them.

See Also