sem_unlink — unlink a named POSIX semaphore
int sem_unlink(const char *name);
is used to unlink named semaphores. A successful call to
marks the semaphore, specified by
for removal. Calling
does not affect processes, including the
calling process, which currently have a descriptor,
obtained from a call to
Named semaphores are uniquely identified by character strings.
All character string names will be pre-processed to ensure variations of
a pathname resolve to the same semaphore name.
If the semaphore is successfully marked for removal by a call to
the semaphore will be
removed when all processes remove their descriptors to the
specified semaphore by calling
Subsequent calls to
using the string
will refer to a new semaphore.
To use this function, link in the realtime library by specifying
on the compiler or linker command line.
The following call to
will remove the named semaphore named by the string
If the semaphore is currently referenced by one or more processes,
the semaphore will be marked for removal and
removed when there are no more processes referencing it.
If the semaphore was unlinked successfully,
If the semaphore could not be unlinked, the call returns -1 and sets
to indicate the error.
fails and does not perform the requested operation
if any of the following conditions are encountered:
The named semaphore exists and the process does not have the permissions to
unlink the semaphore.
string is longer than
is not set in oflag (see
and the named semaphore does not exist.