semget

Return the ID of a semaphore set, possibly creating the set

Declaration

Source position: ipc.pp line 872

  function semget(key: TKey; nsems: cint; semflg: cint) : cint;

Description

msgget returns the ID of the semaphore set described by key. Depending on the flags in semflg, a new queue is created.

semflg can have one or more of the following values (combined by ORs):

IPC_CREAT
The queue is created if it doesn't already exist.
IPC_EXCL
If used in combination with IPC_CREAT, causes the call to fail if the set already exists. It cannot be used by itself.

Optionally, the flags can be ORed with a permission mode, which is the same mode that can be used in the file system.

if a new set of semaphores is created, then there will be nsems semaphores in it.

Errors

On error, -1 is returned, and IPCError is set.

See also

Name Description
ftok Create token from filename
semctl Perform various control operations on a semaphore set
semop Perform semaphore operation.