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

sem_destroy()

Destroy a semaphore

Synopsis:

#include <semaphore.h>

int sem_destroy( sem_t * sem );

Library:

libc

Description:

The sem_destroy() function destroys the unnamed semaphore referred to by the sem argument. The semaphore must have been previously initialized by the sem_init() function.

The effect of using a semaphore after it has been destroyed is undefined. Also, if you destroy a semaphore on which other process's are currently blocked, they are unblocked, with an error (EINVAL).

Returns:

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

Errors:

EINVAL
Invalid semaphore descriptor sem.

Classification:

POSIX 1003.1

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

See also:

sem_init(), sem_post(), sem_trywait(), sem_wait()


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