Create the semaphore if it does not already exist.
The third argument to the call to sem_open must be of type .Vt mode_t and specifies the mode for the semaphore. Only the S_IWUSR, S_IWGRP, and S_IWOTH bits are examined; it is not possible to grant only "read" permission on a semaphore. The mode is modified according to the processs file creation mask; see umask(2).
The fourth argument must be an .Vt "unsigned int" and specifies the initial value for the semaphore, and must be no greater than SEM_VALUE_MAX.
O_EXCL
Create the semaphore if it does not exist. If the semaphore already exists, sem_open will fail. This flag is ignored unless O_CREAT is also specified.
The sem_close function closes a named semaphore that was opened by a call to sem_open.
The sem_unlink function removes the semaphore named name. Resources allocated to the semaphore are only deallocated when all processes that have the semaphore open close it.