Next: , Previous: semop, Up: Semaphores


1.6.3 semctl

     int semctl (int semid, int semnum, int cmd, union semun arg);

The first 4 operate on the semaphore with index semnum in the set. The last two operate on all semaphores in the set.

arg is a union :

     union semun
         int val;               value for SETVAL.
         struct semid_ds *buf;  buffer for IPC_STAT and IPC_SET.
         ushort *array;         array for GETALL and SETALL

Errors: EACCES : do not have permission for specified access.
EFAULT : arg is not accessible.
EIDRM : The resource was removed.
EINVAL : semid < 0 or semnum < 0 or semnum >= nsems.
EPERM : IPC_RMID, IPC_SET ... not creator, owner or super-user.
ERANGE : arg.array[i].semval > SEMVMX or < 0 for some i.