semctl.2 (2010 09)

s
semctl(2) semctl(2)
This cmd can only be executed by a process that has an effective user ID equal to
either that of a user with the
OWNER privilege or to the value of either
sem_perm.uid or sem_perm.cuid
in the data structure associated with semid.
IPC_RMID Remove the semaphore identifier specified by semid from the system and destroy the
set of semaphores and data structure associated with it. This cmd can only be exe-
cuted by a process that has an effective user ID equal to either that of a user with the
OWNER privilege or to the value of either
sem_perm.uid or sem_perm.cuid in
the data structure associated with semid.
Security Restrictions
Some or all of the actions associated with this system call are subject to compartmental restrictions. See
compartments (5) for more information about compartmentalization on systems that support that feature.
Compartmental restrictions can be overridden if the process possesses the
COMMALLOWED privilege
(PRIV_COMMALLOWED). Processes owned by the superuser may not have this privilege. Processes
owned by any user may have this privilege, depending on system configuration.
Some or all of the actions associated with this system call require one or more privileges. Processes
owned by the superuser have many, though not all, privileges. Processes owned by other users may have
privilege(s), depending on system configuration. See privileges (5) for more information about privileged
access on systems that support fine-grained privileges.
RETURN VALUE
Upon successful completion,
semctl() returns a value based on cmd.
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 a user with the OWNER privilege 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 semaphore value 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 respec-
tively. 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;
2 Hewlett-Packard Company 2 HP-UX 11i Version 3: September 2010