Go to the previous, next section.
int semctl(int semid, int semnun, int cmd, union
semun arg);
semid: [in] the semaphore set to manipulate.
semnum: [in] the semaphore in the set to manipulate (0 is the first).
cmd: [in] the operation to perform.
arg: [in out] an argument to the operation (see description).
Manipulates a semaphore set or members of a semaphore set. The possible values for cmd are:
IPC_STAT
IPC_SET
semid_ds
structure of a semaphore in
the set. The members that can be modified are: sem_perm.uid
,
sem_perm.gid
, and the lower 9 bits of sem_perm.mode
. The
calling task must be the owner or the creator of the semaphore set or the
superuser. The sem_ctime
field of the set is updated to the
current time.
IPC_RMID
GETALL
semval
value of all semaphore in an array.
GETNCNT
GETPPID
GETVAL
GETZCNT
SETALL
SETVAL
On success, with cmd equals to:
GETNCNT
GETPID
GETVAL
GETZCNT
For other values of cmd, it returns zero. On error, the call
returns -1 and errno
is set to one of the following values:
EACCESS
, EFAULT
, EIDRM
EINVAL
: invalid value for cmd or semid.
EPERM
: the calling task tried IPC_SET
or
IPC_RMID
but is not the creator or the owner of the semaphore set
or the superuser.
ERANGE
: the specified value for the semaphore is out of
range.
Go to the previous, next section.