semctl(2)semctl(2)NAMEsemctl() - semaphore control operations
SYNOPSISDESCRIPTION
The system call provides a variety of semaphore control operations as
specified by cmd. The fourth argument is optional and depends on the
operation requested. If present, it must be of type which the applica‐
tion program must explicitly declare. For the meaning of unspecified
variables, see in glossary(9).
The following values for cmd are executed with respect to the semaphore
specified by semid and semnum:
Returns the semaphore value.
Requires semaphore Read permission.
Sets the value of the semaphore
to arg.val, where arg is the fourth argument of
taken as a When this cmd is successfully executed,
the semadj value corresponding to the specified
semaphore in all processes is cleared. Requires
semaphore Alter permission.
Returns the pid of the last process that performed a
semaphore operation on this semaphore. Requires
semaphore Read permission.
Returns count of the number of processes that are
currently suspended awaiting this semaphore's value
to become greater than its current value. Requires
semaphore Read permission.
Returns count of the number of processes that are
currently suspended awaiting this semaphore's value
to become zero. Requires semaphore Read permis‐
sion.
The following values for cmd return and set, respectively, every sema‐
phore in the set of semaphores.
Place semaphore value into array pointed to by
arg.array, where arg is the fourth argument of
taken as a Requires semaphore Read permission.
Set semaphore value
according to the array pointed to by arg.array,
where arg is the fourth argument of taken as a When
this cmd is successfully executed, the semadj val‐
ues corresponding to each specified semaphore in
all processes are cleared. Requires semaphore
Alter permission.
The following values for cmd are also available:
Place the current value of each member
of the data structure associated with semid into
the structure pointed to by arg.buf, where arg is
the fourth argument of taken as a The contents of
this structure are defined in glossary(9).
Requires semaphore Read permission.
Set the value of the following members of the data structure
associated with
semid to the corresponding value found in the
structure pointed to by arg.buf, where arg is the
fourth argument of taken as a
This cmd can only be executed by a process that has
an effective user ID equal to either that of a user
with the privilege or to the value of either or in
the data structure associated with semid.
Remove the semaphore identifier specified by
semid from the system and destroy the set of sema‐
phores and data structure associated with it. This
cmd can only be executed by a process that has an
effective user ID equal to either that of a user
with the privilege or to the value of either or 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. Com‐
partmental restrictions can be overridden if the process possesses the
privilege (PRIV_COMMALLOWED). Processes owned by the superuser may not
have this privilege. Processes owned by any user may have this privi‐
lege, 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 privi‐
lege(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, returns a value based on cmd.
All others return
If it fails, it returns and sets to indicate the error.
ERRORS
If fails, it sets to one of the following values:
Operation permission is denied to the calling process (see
in glossary(9).
cmd is or and arg is an invalid pointer.
semid is not a valid semaphore identifier.
semnum is less than zero or greater than or equal
cmd is not a valid command, or the command contains
invalid parameters.
cmd is equal to or and the process does not have an
effective user ID equal to either that of a user
with the privilege or to the value of either or in
the data structure associated with semid.
cmd is or and the value to which semaphore value is to
be set is greater than the system imposed maximum.
EXAMPLES
The following call to 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" oper‐
ations on the semaphores below, refer to semop(2).
SEE ALSOipcrm(1), ipcs(1), semget(2), semop(2), privileges(5), glossary(9).
STANDARDS CONFORMANCEsemctl(2)