HP-UX Reference (11i v1 00/12) - 2 System Calls (vol 5)
__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man2/!!!intro.2
________________________________________________________________
___ ___
s
semctl(2) semctl(2)
associated with semid.
RETURN VALUE
Upon successful completion, semctl() returns a value based on cmd as follows:
GETVAL The value of semval.
GETNCNT The value of semncnt.
GETZCNT The value of semzcnt.
GETPID The value of sempid.
All others return 0.
If it fails, it returns -1 and sets errno to indicate the error.
ERRORS
If semctl() fails, it sets errno to one of the following values:
[EACCES] Operation permission is denied to the calling process (see semaphore operation per-
missions in glossary(9).
[EFAULT] cmd is
SETVAL, GETALL, SETALL, IPC_SET,orIPC_STAT, and arg is an invalid
pointer.
[EINVAL] semid is not a valid semaphore identifier.
[EINVAL] semnum is less than zero or greater than or equal
sem_nsems.
[EINVAL] cmd is not a valid command, or the command contains invalid parameters.
[EPERM] cmd is equal to
IPC_RMID or IPC_SET and the process does not have an effective
user ID equal to either that of superuser or to the value of either sem_perm.uid or
sem_perm.cuid in the data structure associated with semid.
[ERANGE] cmd is SETVAL or SETALL and the value to which semval is to be set is greater than
the system imposed maximum.
EXAMPLES
The following call to semctl() initializes the set of 4 semaphores to the values 0, 1, 0, and 1 respectively.
This example assumes the process has a valid semid representing a set of 4 semaphores as shown in the
semget(2) manual entry. For an example of performing "P" and "V" operations on the semaphores below,
refer to semop(2).
union semun {
int val;
struct semid_ds ∗buf;
ushort ∗array;
} arg;
ushort semarray[4];
semarray[0] = 0;
semarray[1] = 1;
semarray[2] = 0;
semarray[3] = 1;
arg.array = &semarray[0];
semctl (mysemid, 0, SETALL, arg);
SEE ALSO
ipcrm(1), ipcs(1), semget(2), semop(2), stdipc(3C), glossary(9).
STANDARDS CONFORMANCE
semctl(): SVID2, SVID3, XPG2, XPG3, XPG4
Section 2−−288 − 2 − HP-UX Release 11i: December 2000
___
___