Use sema_destroy(3C) to destroy any state that is associated with the semaphore pointed to by sp. The space for storing the semaphore is not freed.
#include <thread.h> int sema_destroy(sema_t *sp);
sema_destroy() returns 0 if successful. When the following condition is detected, sema_destroy() fails and returns the corresponding value.
EINVAL
Description:sp refers to an invalid semaphore.