Destroys an unnamed semaphore.
Standard C Library (libc.a)
#include <semaphore.h>
int sem_destroy (sem)
sem_t *sem;
The sem_destroy subroutine destroys the unnamed semaphore indicated by the sem parameter. Only a semaphore that was created using the sem_init subroutine can be destroyed using the sem_destroy subroutine; calling sem_destroy with a named semaphore returns an error. Subsequent use of the semaphore sem returns an error until sem is reinitialized by another call to sem_init. It is safe to destroy an initialized semaphore upon which other threads are currently blocked.
Item | Description |
---|---|
sem | Indicates the semaphore to be closed. |
Upon successful completion, 0 is returned. Otherwise, -1 is returned and errno set to indicate the error.
Item | Description |
---|---|
EACCES | Permission is denied to destroy the unnamed semaphore. |
EFAULT | Invalid user address. |
EINVAL | The sem parameter is not a valid semaphore. |
ENOTSUP | This function is not supported with processes that have been checkpoint-restart'ed. |