sema_wait() returns 0 if successful. When any of the following conditions is detected, sema_wait() fails and returns the corresponding value.
EINVAL
Description:sp refers to an invalid semaphore.
EINTR
Description:The wait was interrupted by a signal.