[Previous] [Contents] [Index] [Next]

sem_unlink()

Destroy a named semaphore

Synopsis:

#include <semaphore.h>

int sem_unlink( const char * sem_name );

Library:

libc

Description:

The sem_unlink() function destroys the named semaphore, sem_name. Open semaphores are removed the same way unlink() removes open files; the processes that have the semaphore open can still use it, but the semaphore will disappear as soon as the last process uses sem_close() to close it. Any attempt to sem_open() an unlinked semaphore will refer to a new semaphore.

Semaphores are persistent as long as the system remains up.

Returns:

0
Success.
-1
An error occurred (errno is set).

Errors:

EACCESS
You don't have permission to unlink the semaphore.
ELOOP
Too many levels of symbolic links or prefixes.
ENOENT
The semaphore sem_name doesn't exist.
ENAMETOOLONG
The sem_name argument is longer than (NAME_MAX - 8).
ENOSYS
The sem_unlink() function isn't implemented for the filesystem specified in path.

Classification:

POSIX 1003.1

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

Caveats:

The mqueue manager must be running for applications to use named semaphores.

See also:

sem_open(), sem_close(), sem_wait(), sem_trywait(), sem_post()


[Previous] [Contents] [Index] [Next]