sema_destroy() returns 0 if successful. When the following condition is detected, sema_destroy() fails and returns the corresponding value.
EINVAL
sp refers to an invalid semaphore.