#include <sys/types.h> #include <sys/ipc.h> #include <sys/sem.h>
int semctl(semid, semnum, cmd, arg) int semid, semnum, cmd; union semun { val; struct semid_ds *buf; ushort *array; } arg;
The following cmds are executed with respect to the semaphore specified by semid and semnum:
The following cmds return and set, respectively, every semval in the set of semaphores.
The following cmds are also available:
sem_perm.uid
sem_perm.gid
sem_perm.mode /* only low 9 bits */
This
cmd
can only be executed by a process that has an effective user
ID
equal to either that of super-user, or to the value of
sem_perm.cuid
or
sem_perm.uid
in the data structure associated with
semid.
In the semop.2 and semctl.2 system call descriptions, the permission required for an operation is given as "[token]", where ``token'' is the type of permission needed interpreted as follows:
Read and Alter permissions on a semid are granted to a process if one or more of the following are true:
The effective user ID of the process is super-user.
The effective user ID of the process matches sem_perm.[c]uid in the data structure associated with semid and the appropriate bit of the ``user'' portion (0600) of sem_perm.mode is set.
The effective user ID of the process does not match sem_perm.[c]uid and the effective group ID of the process matches sem_perm.[c]gid and the appropriate bit of the ``group'' portion (060) of sem_perm.mode is set.
The effective user ID of the process does not match sem_perm.[c]uid and the effective group ID of the process does not match sem_perm.[c]gid and the appropriate bit of the ``other'' portion (06) of sem_perm.mode is set.
Otherwise, the corresponding permissions are denied.
On success, the value returned by semctl() depends on cmd as follows:
On failure, semctl() returns -1 and sets errno to indicate the error.
semnum is less than zero or greater than sem_nsems.
cmd is not a valid command.
cmd is IPC_RMID or IPC_SET and the effective user ID of the calling process is not the value of sem_perm.cuid or sem_perm.uid in the data structure associated with semid.
Created by unroff & hp-tools. © somebody (See intro for details). All Rights Reserved. Last modified 11/5/97