sem_init() returns zero after completing successfully. Any other return value indicates that an error occurred. When any of the following conditions occurs, the function fails and returns the corresponding value.
EINVAL
Description:The value argument exceeds SEM_VALUE_MAX .
ENOSPC
Description:A resource that is required to initialize the semaphore has been exhausted. The limit on semaphores SEM_NSEMS_MAX has been reached.
EPERM
Description:The process lacks the appropriate privileges to initialize the semaphore.