Removes a named semaphore.
Standard C Library (libc.a)
#include <semaphore.h>
int sem_unlink (name)
const char *name;
The sem_unlink subroutine removes the semaphore named by the string name.
If the semaphore named by name is currently referenced by other processes, then sem_unlink has no effect on the state of the semaphore. If one or more processes have the semaphore open when sem_unlink is called, destruction of the semaphore is postponed until all references to the semaphore have been destroyed by calls to sem_close, _exit, or exec. Calls to sem_open to recreate or reconnect to the semaphore refer to a new semaphore after sem_unlink is called.
The sem_unlink subroutine does not block until all references have been destroyed, and it returns immediately.
Item | Description |
---|---|
name | Specifies the name of the semaphore to be unlinked. |
Upon successful completion, the sem_unlink subroutine returns a 0. Otherwise, the semaphore remains unchanged, -1 is returned, and errno is set to indicate the error.
Item | Description |
---|---|
EACCES | Permission is denied to unlink the named semaphore. |
EFAULT | Invalid user address. |
ENAMETOOLONG | The length of the name parameter exceeds PATH_MAX or a pathname component is longer than NAME_MAX. |
ENOENT | The named semaphore does not exist. |
ENOTSUP | This function is not supported with processes that have been checkpoint-restart'ed. |