Prototype: int sem_destroy(sem_t *sem);
#include <semaphore.h> sem_t sem; int ret; ret = sem_destroy(&sem); /* the semaphore is destroyed */
Use sem_destroy() to destroy any state associated with the semaphore pointed to by sem. The space for storing the semaphore is not freed.
sem_destroy() returns zero after completing successfully. Any other returned value indicates that an error occurred. When the following condition occurs, the function fails and returns the corresponding value.