Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

semctl(2) [hpux man page]

semctl(2)							System Calls Manual							 semctl(2)

NAME
semctl() - semaphore control operations SYNOPSIS
DESCRIPTION
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 application 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 permission. The following values for cmd return and set, respectively, every semaphore 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 suc- cessfully executed, the semadj values 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 privi- lege 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 semaphores 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 infor- mation about compartmentalization on systems that support that feature. Compartmental restrictions can be overridden if the process pos- sesses the 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, 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" opera- tions on the semaphores below, refer to semop(2). SEE ALSO
ipcrm(1), ipcs(1), semget(2), semop(2), privileges(5), glossary(9). STANDARDS CONFORMANCE
semctl(2)
Man Page