Upon successful return, the state of the semaphore is locked and remains locked until the sem_post() function is executed and returns successfully.
The sem_wait() function is interruptible by the delivery of a signal.
RETURN VALUE
The sem_wait() and sem_trywait() functions return zero if the calling process successfully performed the semaphore lock operation on the semaphore designated by sem. If the call was unsuccessful, the state of the semaphore is unchanged, and the function returns a value of -1 and sets errno to indicate the error.
ERRORS
...
The sem_wait() and sem_trywait() functions may fail if:
...
[EINTR]
A signal interrupted this function.