#include <semaphore.h> int sem_destroy(sem_t * sem);
|
The sem_destroy() function destroys an unnamed semaphore that was previously initialized using sem_init() or sem_init_np(). Any threads that have blocked from calling sem_wait() or sem_wait_np() on the semaphore will unblock and return an [EINVAL] or [EDESTROYED] error.
Parameters
Authorities
None
Return Value
Error Conditions
If sem_destroy() is not successful, errno usually indicates one of the following errors. Under some conditions, errno could indicate an error other than those listed here.
An attempt was made to use a system resource that is not available at this time.
The semaphore is being destroyed by another thread.
A function was passed incorrect argument values, or an operation was attempted on an object and the operation specified is not supported for that type of object.
An argument value is not valid, out of range, or NULL.
The sem parameter is not a valid semaphore.
Error Messages
None.
Related Information
Example
The following example initializes an unnamed semaphore, my_semaphore, that will be used by threads of the current process and sets its value to 10. The semaphore is then destroyed using sem_destroy().
#include <semaphore.h>
main() {
sem_t my_semaphore;
int rc;
rc = sem_init(&my_semaphore, 0, 10);
rc = sem_destroy(&my_semaphore);
}
| Top | Interprocess Communication APIs | APIs by category |
| [Information Center Home Page | Feedback ] | [Legal | AS/400 Glossary] |