sem_getvalue(3R)
NAME
sem_getvalue − get the value of a semaphore
SYNOPSIS
cc [ flag ... ] file ... −lposix4 [ library ... ]
#include <semaphore.h>
int sem_getvalue(sem_t ∗sem, int ∗sval);
DESCRIPTION
The sem_getvalue() function updates the location referenced by sval to have the value of the semaphore referenced by sem without affecting the state of the semaphore. The updated value represents an actual semaphore value that occurred at some unspecified time during the call to sem_getvalue(), but may not be the actual value of the semaphore when sem_getvalue() is returned to the caller.
The value set in sval may be 0 or positive. If sval is 0, there may be other processes (or LWPs or threads) waiting for the semaphore; if sval is positive, no one is waiting.
RETURN VALUES
If successful, sem_getvalue() returns 0, otherwise, it returns −1, and sets errno to indicate the error condition.
ERRORS
EINVAL The sem argument does not refer to a valid semaphore.
ENOSYS The sem_getvalue() function is not supported.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
| MT-Level | MT-Safe |
SEE ALSO
sem_post(3R), sem_wait(3R), attributes(5)
SunOS 5.6 — Last change: 30 Dec 1996